// File: roberty65[P]bServer/serverd/src/main.cpp
// Function: loadConfig(char const*)
static int loadConfig(const char *file)
{
	ConfigProperty cfp;
	if (cfp.parse(file) < 0) return -1;

	const char *val = cfp.getString("logLevel", "ERROR");
	if (strcmp(val, "FATAL") == 0) logLevel = LOG_LEVEL_FATAL;
	else if (strcmp(val, "ERROR") == 0) logLevel = LOG_LEVEL_ERROR;
	else if (strcmp(val, "WARN") == 0) logLevel = LOG_LEVEL_WARN;
	else if (strcmp(val, "INFO") == 0) logLevel = LOG_LEVEL_INFO;
	else if (strcmp(val, "DEBUG") == 0) logLevel = LOG_LEVEL_DEBUG;
	else logLevel = LOG_LEVEL_ERROR;
	
	val = cfp.getString("logFileName", "../logs/server.log");	
	if ((logFileName = strdup(val)) == NULL) return -1;
	
	logFileMaxSize = cfp.getInt("logFileMaxSize", 10*1024*1024);
	logMaxBackup = cfp.getInt("logMaxBackup", 10);

	val = cfp.getString("listenAddress", "tcp://*:6010");
	if ((listenAddress = strdup(val)) == NULL) return -1;
	
	listenBacklog = cfp.getInt("listenBacklog", 1024);
	listenMaxConnection = cfp.getInt("listenMaxConnection", 8192);

	systemThreadCount = cfp.getInt("systemThreadCount", 8);
	systemInQueueSize = cfp.getInt("systemInQueueSize", 8192);
	systemOutQueueSize = cfp.getInt("systemOutQueueSize", 16384);
	systemInMessageExpire = cfp.getInt("systemInMessageExpire", 30);
	systemOutMessageExpire = cfp.getInt("systemOutMessageExpire", 30);

	val = cfp.getString("businessProcessor", "../lib/libEcho.so");
	if ((businessProcessor = strdup(val)) == NULL) return -1;

	connectionIdleTimeout = cfp.getInt("connectionIdleTimeout", 10);
	connectionOutQueueSize = cfp.getInt("connectionOutQueueSize", 100);

	connectorHelloInterval = cfp.getInt("connectorHelloInterval", 3);
	reconnectDelay = cfp.getInt("reconnectDelay", 2);

	std::set<std::string> ctrs = cfp.getChildren("connector");
	for (std::set<std::string>::iterator iter = ctrs.begin();
		iter != ctrs.end();
			++iter) {
		val = cfp.getString("connector", iter->c_str(), "address", NULL);
		if (val == NULL || (val = strdup(val)) == NULL) return -1;
		if (val != NULL) {
			connectors.insert(std::make_pair(*iter, ConnectorInfo(val, -1)));
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x10(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x51f0
movq -0xf8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xdcc0
movl %eax, -0xec(%rbp)
jmp 0x4337
movl -0xec(%rbp), %eax
cmpl $0x0, %eax
jge 0x4366
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x50(%rbp)
jmp 0x4934
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x4949
leaq 0xdf2c(%rip), %rsi      # 0x12299
leaq 0xdf2e(%rip), %rdx      # 0x122a2
leaq -0x40(%rbp), %rdi
callq 0xe1f0
movq %rax, -0x100(%rbp)
jmp 0x4386
movq -0x100(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
leaq 0xdf0c(%rip), %rsi      # 0x122a8
callq 0x3570
cmpl $0x0, %eax
jne 0x43b5
movl $0x1, 0x16168(%rip)     # 0x1a518
jmp 0x444b
movq -0x58(%rbp), %rdi
leaq 0xdee2(%rip), %rsi      # 0x122a2
callq 0x3570
cmpl $0x0, %eax
jne 0x43d6
movl $0x2, 0x16144(%rip)     # 0x1a518
jmp 0x4449
movq -0x58(%rbp), %rdi
leaq 0xdecd(%rip), %rsi      # 0x122ae
callq 0x3570
cmpl $0x0, %eax
jne 0x43f7
movl $0x3, 0x16123(%rip)     # 0x1a518
jmp 0x4447
movq -0x58(%rbp), %rdi
leaq 0xdeb1(%rip), %rsi      # 0x122b3
callq 0x3570
cmpl $0x0, %eax
jne 0x4418
movl $0x4, 0x16102(%rip)     # 0x1a518
jmp 0x4445
movq -0x58(%rbp), %rdi
leaq 0xde95(%rip), %rsi      # 0x122b8
callq 0x3570
cmpl $0x0, %eax
jne 0x4439
movl $0x5, 0x160e1(%rip)     # 0x1a518
jmp 0x4443
movl $0x2, 0x160d5(%rip)     # 0x1a518
jmp 0x4445
jmp 0x4447
jmp 0x4449
jmp 0x444b
leaq 0xde6c(%rip), %rsi      # 0x122be
leaq 0xde71(%rip), %rdx      # 0x122ca
leaq -0x40(%rbp), %rdi
callq 0xe1f0
movq %rax, -0x108(%rbp)
jmp 0x446b
movq -0x108(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x36f0
movq %rax, 0x1608a(%rip)     # 0x1a510
cmpq $0x0, %rax
jne 0x449f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x50(%rbp)
jmp 0x4934
leaq 0xde37(%rip), %rsi      # 0x122dd
leaq -0x40(%rbp), %rdi
movl $0xa00000, %edx         # imm = 0xA00000
callq 0xe380
movl %eax, -0x10c(%rbp)
jmp 0x44bc
movl -0x10c(%rbp), %eax
cltq
movq %rax, 0x16055(%rip)     # 0x1a520
leaq 0xde1a(%rip), %rsi      # 0x122ec
leaq -0x40(%rbp), %rdi
movl $0xa, %edx
callq 0xe380
movl %eax, -0x110(%rbp)
jmp 0x44e8
movl -0x110(%rbp), %eax
cltq
movq %rax, 0x16031(%rip)     # 0x1a528
leaq 0xddfb(%rip), %rsi      # 0x122f9
leaq 0xde02(%rip), %rdx      # 0x12307
leaq -0x40(%rbp), %rdi
callq 0xe1f0
movq %rax, -0x118(%rbp)
jmp 0x4517
movq -0x118(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x36f0
movq %rax, 0x160ae(%rip)     # 0x1a5e0
cmpq $0x0, %rax
jne 0x454b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x50(%rbp)
jmp 0x4934
leaq 0xddc2(%rip), %rsi      # 0x12314
leaq -0x40(%rbp), %rdi
movl $0x400, %edx            # imm = 0x400
callq 0xe380
movl %eax, -0x11c(%rbp)
jmp 0x4568
movl -0x11c(%rbp), %eax
movl %eax, 0x15fe4(%rip)     # 0x1a558
leaq 0xdda7(%rip), %rsi      # 0x12322
leaq -0x40(%rbp), %rdi
movl $0x2000, %edx           # imm = 0x2000
callq 0xe380
movl %eax, -0x120(%rbp)
jmp 0x4591
movl -0x120(%rbp), %eax
movl %eax, 0x15fb3(%rip)     # 0x1a550
leaq 0xdd92(%rip), %rsi      # 0x12336
leaq -0x40(%rbp), %rdi
movl $0x8, %edx
callq 0xe380
movl %eax, -0x124(%rbp)
jmp 0x45ba
movl -0x124(%rbp), %eax
movl %eax, 0x15f8e(%rip)     # 0x1a554
leaq 0xdd7b(%rip), %rsi      # 0x12348
leaq -0x40(%rbp), %rdi
movl $0x2000, %edx           # imm = 0x2000
callq 0xe380
movl %eax, -0x128(%rbp)
jmp 0x45e3
movl -0x128(%rbp), %eax
movl %eax, 0x15f41(%rip)     # 0x1a530
leaq 0xdd64(%rip), %rsi      # 0x1235a
leaq -0x40(%rbp), %rdi
movl $0x4000, %edx           # imm = 0x4000
callq 0xe380
movl %eax, -0x12c(%rbp)
jmp 0x460c
movl -0x12c(%rbp), %eax
movl %eax, 0x15f1c(%rip)     # 0x1a534
leaq 0xdd4e(%rip), %rsi      # 0x1236d
leaq -0x40(%rbp), %rdi
movl $0x1e, %edx
callq 0xe380
movl %eax, -0x130(%rbp)
jmp 0x4635
movl -0x130(%rbp), %eax
movl %eax, 0x15ef7(%rip)     # 0x1a538
leaq 0xdd3b(%rip), %rsi      # 0x12383
leaq -0x40(%rbp), %rdi
movl $0x1e, %edx
callq 0xe380
movl %eax, -0x134(%rbp)
jmp 0x465e
movl -0x134(%rbp), %eax
movl %eax, 0x15ed2(%rip)     # 0x1a53c
leaq 0xdd29(%rip), %rsi      # 0x1239a
leaq 0xdd34(%rip), %rdx      # 0x123ac
leaq -0x40(%rbp), %rdi
callq 0xe1f0
movq %rax, -0x140(%rbp)
jmp 0x468a
movq -0x140(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x36f0
movq %rax, 0x15f33(%rip)     # 0x1a5d8
cmpq $0x0, %rax
jne 0x46be
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x50(%rbp)
jmp 0x4934
leaq 0xdcf9(%rip), %rsi      # 0x123be
leaq -0x40(%rbp), %rdi
movl $0xa, %edx
callq 0xe380
movl %eax, -0x144(%rbp)
jmp 0x46db
movl -0x144(%rbp), %eax
movl %eax, 0x15e59(%rip)     # 0x1a540
leaq 0xdce6(%rip), %rsi      # 0x123d4
leaq -0x40(%rbp), %rdi
movl $0x64, %edx
callq 0xe380
movl %eax, -0x148(%rbp)
jmp 0x4704
movl -0x148(%rbp), %eax
movl %eax, 0x15e34(%rip)     # 0x1a544
leaq 0xdcd4(%rip), %rsi      # 0x123eb
leaq -0x40(%rbp), %rdi
movl $0x3, %edx
callq 0xe380
movl %eax, -0x14c(%rbp)
jmp 0x472d
movl -0x14c(%rbp), %eax
movl %eax, 0x15e0f(%rip)     # 0x1a548
leaq 0xdcc2(%rip), %rsi      # 0x12402
leaq -0x40(%rbp), %rdi
movl $0x2, %edx
callq 0xe380
movl %eax, -0x150(%rbp)
jmp 0x4756
movl -0x150(%rbp), %eax
movl %eax, 0x15dea(%rip)     # 0x1a54c
leaq 0xdca8(%rip), %rdx      # 0x12411
leaq -0x88(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0xe6a0
jmp 0x477b
leaq -0x88(%rbp), %rdi
callq 0x5210
movq %rax, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x5270
movq %rax, -0x98(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x5240
testb $0x1, %al
jne 0x47bd
jmp 0x490a
leaq -0x90(%rbp), %rdi
callq 0x52a0
movq %rax, %rdi
callq 0x3150
movq %rax, %rdx
leaq 0xdc36(%rip), %rsi      # 0x12411
leaq 0xdc39(%rip), %rcx      # 0x1241b
xorl %eax, %eax
movl %eax, %r8d
leaq -0x40(%rbp), %rdi
callq 0xe300
movq %rax, -0x158(%rbp)
jmp 0x47f9
movq -0x158(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x481e
movq -0x58(%rbp), %rdi
callq 0x36f0
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
jne 0x4842
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x50(%rbp)
jmp 0x4918
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x4926
cmpq $0x0, -0x58(%rbp)
je 0x48f7
leaq -0x90(%rbp), %rdi
callq 0x5350
movq %rax, -0x160(%rbp)
movq -0x58(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5370
jmp 0x4877
movq -0x160(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
leaq -0xd8(%rbp), %rdx
callq 0x5310
jmp 0x4893
leaq 0x15d0e(%rip), %rdi     # 0x1a5a8
leaq -0xc8(%rbp), %rsi
callq 0x52d0
movb %dl, -0x169(%rbp)
movq %rax, -0x168(%rbp)
jmp 0x48b5
movb -0x169(%rbp), %al
movq -0x168(%rbp), %rcx
movq %rcx, -0xe8(%rbp)
movb %al, -0xe0(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x53a0
jmp 0x48f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x53a0
jmp 0x4926
jmp 0x48f9
leaq -0x90(%rbp), %rdi
callq 0x53c0
jmp 0x478e
movl $0x0, -0x4(%rbp)
movl $0x1, -0x50(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x53f0
jmp 0x4934
leaq -0x88(%rbp), %rdi
callq 0x53f0
jmp 0x4949
leaq -0x40(%rbp), %rdi
callq 0x5410
movl -0x4(%rbp), %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0x5410
movq -0x48(%rbp), %rdi
callq 0x3690
nopl (%rax,%rax)