// File: wangyufei95[P]watchdog_linux/./maile.h
// Function: CAutoMail::send_mail()
bool CAutoMail::send_mail()
{
	m_str_src_mail_p;
	m_str_pwd_p;
	m_str_dst_mail_p;
	
	base64(m_str_src_mail_p, STR_BASE_FILE);
	base64(m_str_pwd_p, STR_BASE_FILE);
	base64(m_str_dst_mail_p, STR_BASE_FILE);
	

	char buf_send[BUF_LEN] = {0};
	char buf_recv[BUF_LEN] = {0};
	char buf_time[BUF_LEN] = {0};

	ofstream ofs(STR_LOG_FILE);
	wchar_t _buf_info[BUF_LEN] = {0};
	char buf[BUF_LEN] = {0};
	
	wifstream ifs(STR_BASE_FILE);
	ifs.getline(_buf_info,sizeof(_buf_info));
	m_str_src_mail_c = _buf_info;
	memset(_buf_info, 0, sizeof(_buf_info));
	ifs.getline(_buf_info,sizeof( _buf_info));
	m_str_pwd_c = _buf_info;
	memset(_buf_info, 0, sizeof( _buf_info));
	ifs.getline(_buf_info,sizeof(_buf_info));
	m_str_dst_mail_c = _buf_info;
	ifs.close();
	
	int reval = connect(m_socket_server, (struct sockaddr*)&m_sockaddr_server, sizeof(struct sockaddr));
	// connect to mail server
	if (reval != 0)
	{
		ERROR_NUMBER = CONNECT_SERVER_FAILED;
		uninit();
		return false;
	}

	recv(m_socket_server, buf, sizeof(buf), 0); // get welcome message from server
	memset (buf_time, 0, sizeof(buf_time));
	get_time(buf_time);
	ofs << buf_time << ": " << buf;
	
	send_mail_head(ofs);
	send_mail_data(ofs);
	
	ofs.close();
	cout << "send completed." << endl;
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd20, %rsp            # imm = 0xD20
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rsi
movq %rsi, -0xca0(%rbp)
addq $0x8, %rsi
leaq -0x30(%rbp), %rdi
movq %rdi, -0xc98(%rbp)
callq 0x3380
movq -0xca0(%rbp), %rdi
movq -0xc98(%rbp), %rsi
movq 0xbee5(%rip), %rdx      # 0x113e8
callq 0x4680
jmp 0x550a
leaq -0x30(%rbp), %rdi
callq 0x3680
movq -0xca0(%rbp), %rsi
addq $0x88, %rsi
leaq -0x60(%rbp), %rdi
movq %rdi, -0xca8(%rbp)
callq 0x3380
movq -0xca0(%rbp), %rdi
movq -0xca8(%rbp), %rsi
movq 0xbea2(%rip), %rdx      # 0x113e8
callq 0x4680
jmp 0x554d
leaq -0x60(%rbp), %rdi
callq 0x3680
movq -0xca0(%rbp), %rsi
addq $0x48, %rsi
leaq -0x80(%rbp), %rdi
movq %rdi, -0xcb0(%rbp)
callq 0x3380
movq -0xca0(%rbp), %rdi
movq -0xcb0(%rbp), %rsi
movq 0xbe62(%rip), %rdx      # 0x113e8
callq 0x4680
jmp 0x558d
leaq -0x80(%rbp), %rdi
callq 0x3680
xorps %xmm0, %xmm0
movaps %xmm0, -0xcc0(%rbp)
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movaps %xmm0, -0xc0(%rbp)
movaps %xmm0, -0xd0(%rbp)
movaps %xmm0, -0xe0(%rbp)
movaps %xmm0, -0xf0(%rbp)
movaps %xmm0, -0x100(%rbp)
movaps %xmm0, -0x110(%rbp)
movaps %xmm0, -0x120(%rbp)
movaps %xmm0, -0x130(%rbp)
movaps %xmm0, -0x140(%rbp)
movaps %xmm0, -0x150(%rbp)
movaps %xmm0, -0x160(%rbp)
movaps %xmm0, -0x170(%rbp)
movaps %xmm0, -0x180(%rbp)
movaps %xmm0, -0x190(%rbp)
movaps %xmm0, -0x1a0(%rbp)
movaps %xmm0, -0x1b0(%rbp)
movaps %xmm0, -0x1c0(%rbp)
movaps %xmm0, -0x1d0(%rbp)
movaps %xmm0, -0x1e0(%rbp)
movaps %xmm0, -0x1f0(%rbp)
movaps %xmm0, -0x200(%rbp)
movaps %xmm0, -0x210(%rbp)
movaps %xmm0, -0x220(%rbp)
movaps %xmm0, -0x230(%rbp)
movaps %xmm0, -0x240(%rbp)
movaps %xmm0, -0x250(%rbp)
movaps %xmm0, -0x260(%rbp)
movaps %xmm0, -0x270(%rbp)
movaps %xmm0, -0x280(%rbp)
movaps %xmm0, -0x290(%rbp)
movaps %xmm0, -0x2a0(%rbp)
movaps %xmm0, -0x2b0(%rbp)
movaps %xmm0, -0x2c0(%rbp)
movaps %xmm0, -0x2d0(%rbp)
movaps %xmm0, -0x2e0(%rbp)
movaps %xmm0, -0x2f0(%rbp)
movaps %xmm0, -0x300(%rbp)
movaps %xmm0, -0x310(%rbp)
movaps %xmm0, -0x320(%rbp)
movaps %xmm0, -0x330(%rbp)
movaps %xmm0, -0x340(%rbp)
movaps %xmm0, -0x350(%rbp)
movaps %xmm0, -0x360(%rbp)
movaps %xmm0, -0x370(%rbp)
movaps %xmm0, -0x380(%rbp)
movq 0xbcf9(%rip), %rsi      # 0x113f0
leaq -0x580(%rbp), %rdi
movl $0x10, %edx
callq 0x3440
leaq -0x980(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x3220
movaps -0xcc0(%rbp), %xmm0
movaps %xmm0, -0x990(%rbp)
movaps %xmm0, -0x9a0(%rbp)
movaps %xmm0, -0x9b0(%rbp)
movaps %xmm0, -0x9c0(%rbp)
movaps %xmm0, -0x9d0(%rbp)
movaps %xmm0, -0x9e0(%rbp)
movaps %xmm0, -0x9f0(%rbp)
movaps %xmm0, -0xa00(%rbp)
movaps %xmm0, -0xa10(%rbp)
movaps %xmm0, -0xa20(%rbp)
movaps %xmm0, -0xa30(%rbp)
movaps %xmm0, -0xa40(%rbp)
movaps %xmm0, -0xa50(%rbp)
movaps %xmm0, -0xa60(%rbp)
movaps %xmm0, -0xa70(%rbp)
movaps %xmm0, -0xa80(%rbp)
movq 0xbc4f(%rip), %rsi      # 0x113e8
leaq -0xc88(%rbp), %rdi
movl $0x8, %edx
callq 0x3310
jmp 0x57ac
leaq -0xc88(%rbp), %rdi
leaq -0x980(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x33a0
jmp 0x57c6
movq -0xca0(%rbp), %rdi
addq $0x28, %rdi
leaq -0x980(%rbp), %rsi
callq 0x3720
jmp 0x57df
leaq -0x980(%rbp), %rdi
movq %rdi, -0xcd0(%rbp)
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
movq %rdx, -0xcc8(%rbp)
callq 0x3220
movq -0xcd0(%rbp), %rsi
movq -0xcc8(%rbp), %rdx
leaq -0xc88(%rbp), %rdi
callq 0x33a0
jmp 0x581c
movq -0xca0(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x980(%rbp), %rsi
callq 0x3720
jmp 0x5838
leaq -0x980(%rbp), %rdi
movq %rdi, -0xce0(%rbp)
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
movq %rdx, -0xcd8(%rbp)
callq 0x3220
movq -0xce0(%rbp), %rsi
movq -0xcd8(%rbp), %rdx
leaq -0xc88(%rbp), %rdi
callq 0x33a0
jmp 0x5875
movq -0xca0(%rbp), %rdi
addq $0x68, %rdi
leaq -0x980(%rbp), %rsi
callq 0x3720
jmp 0x588e
leaq -0xc88(%rbp), %rdi
callq 0x3070
jmp 0x589c
movq -0xca0(%rbp), %rsi
movl 0x32c(%rsi), %edi
addq $0x330, %rsi            # imm = 0x330
movl $0x10, %edx
callq 0x3330
movl %eax, -0xce4(%rbp)
jmp 0x58c2
movl -0xce4(%rbp), %eax
movl %eax, -0xc8c(%rbp)
cmpl $0x0, -0xc8c(%rbp)
je 0x5982
movq -0xca0(%rbp), %rdi
movl $0x13, 0xbb14(%rip)     # 0x11400
callq 0x45b0
jmp 0x58f3
movb $0x0, -0x1(%rbp)
movl $0x1, -0xc90(%rbp)
jmp 0x5afc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3680
jmp 0x5b2e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3680
jmp 0x5b2e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x3680
jmp 0x5b2e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x5b22
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xc88(%rbp), %rdi
callq 0x32e0
jmp 0x5b22
movq -0xca0(%rbp), %rax
movl 0x32c(%rax), %edi
leaq -0xa80(%rbp), %rsi
movl $0x100, %edx            # imm = 0x100
xorl %ecx, %ecx
callq 0x30f0
jmp 0x59a4
movq -0xca0(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, -0xd10(%rbp)
movaps %xmm0, -0x290(%rbp)
movaps %xmm0, -0x2a0(%rbp)
movaps %xmm0, -0x2b0(%rbp)
movaps %xmm0, -0x2c0(%rbp)
movaps %xmm0, -0x2d0(%rbp)
movaps %xmm0, -0x2e0(%rbp)
movaps %xmm0, -0x2f0(%rbp)
movaps %xmm0, -0x300(%rbp)
movaps %xmm0, -0x310(%rbp)
movaps %xmm0, -0x320(%rbp)
movaps %xmm0, -0x330(%rbp)
movaps %xmm0, -0x340(%rbp)
movaps %xmm0, -0x350(%rbp)
movaps %xmm0, -0x360(%rbp)
movaps %xmm0, -0x370(%rbp)
movaps %xmm0, -0x380(%rbp)
leaq -0x380(%rbp), %rsi
movq %rsi, -0xcf8(%rbp)
callq 0x48b0
movq -0xcf8(%rbp), %rsi
leaq -0x580(%rbp), %rdi
callq 0x33e0
movq %rax, -0xcf0(%rbp)
jmp 0x5a54
movq -0xcf0(%rbp), %rdi
leaq 0x6bdc(%rip), %rsi      # 0xc63e
callq 0x33e0
movq %rax, -0xd18(%rbp)
jmp 0x5a70
movq -0xd18(%rbp), %rdi
leaq -0xa80(%rbp), %rsi
callq 0x33e0
jmp 0x5a85
movq -0xca0(%rbp), %rdi
leaq -0x580(%rbp), %rsi
callq 0x4940
jmp 0x5a9a
movq -0xca0(%rbp), %rdi
leaq -0x580(%rbp), %rsi
callq 0x4d70
jmp 0x5aaf
leaq -0x580(%rbp), %rdi
callq 0x35a0
jmp 0x5abd
movq 0xb4f4(%rip), %rdi      # 0x10fb8
leaq 0x6684(%rip), %rsi      # 0xc14f
callq 0x33e0
movq %rax, -0xd20(%rbp)
jmp 0x5ad9
movq -0xd20(%rbp), %rdi
movq 0xb4b9(%rip), %rsi      # 0x10fa0
callq 0x3410
jmp 0x5aee
movb $0x1, -0x1(%rbp)
movl $0x1, -0xc90(%rbp)
leaq -0xc88(%rbp), %rdi
callq 0x32e0
leaq -0x580(%rbp), %rdi
callq 0x35f0
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xd20, %rsp            # imm = 0xD20
popq %rbp
retq
leaq -0x580(%rbp), %rdi
callq 0x35f0
movq -0x38(%rbp), %rdi
callq 0x36e0
nopw (%rax,%rax)