// File: /workspace/github_cpp_makefile_star2_O3/qian-jiahong[P]uvncrep017-ws/readini.cpp
// Function: readIniFile(char*)
bool readIniFile(char *iniFilePathAndName)
{
    dictionary *dict;
    int ii;
    char tmpBuf[MY_TMP_BUF_LEN];
    char tmpBuf2[MY_TMP_BUF_LEN];
    
    dict = iniparser_new(iniFilePathAndName);
    
    if (dict != NULL) {        
        //General settings
        //General settings
        viewerPort = iniparser_getint(dict, "general:viewerport", 5900);    
        serverPort = iniparser_getint(dict, "general:serverport", 5500);    

        maxSessions = iniparser_getint(dict, "general:maxsessions", MAX_SESSIONS_DEFAULT);
        if (maxSessions > MAX_SESSIONS_MAX)
            maxSessions = MAX_SESSIONS_DEFAULT;
        if (maxSessions < MAX_SESSIONS_MIN)
            maxSessions = MAX_SESSIONS_DEFAULT;

        allowedModes = iniparser_getint(dict, "general:allowedmodes", (CONN_MODE1 | CONN_MODE2));     
        
        strlcpy(ownIpAddress, iniparser_getstring(dict, "general:ownipaddress", "0.0.0.0"), MY_TMP_BUF_LEN);
        
        strlcpy(runAsUser, iniparser_getstring(dict, "general:runasuser", "uvncrep"), MY_TMP_BUF_LEN);
                
        loggingLevel = iniparser_getint(dict, "general:logginglevel", DEFAULT_LOGGING_LEVEL);     
        if (loggingLevel > LEVEL_3)
            loggingLevel = DEFAULT_LOGGING_LEVEL;
        if (loggingLevel < LEVEL_0)
            loggingLevel = DEFAULT_LOGGING_LEVEL;

        
        //Mode 1 settings
        //Mode 1 settings
        allowedMode1ServerPort = iniparser_getint(dict, "mode1:allowedmode1serverport", 0);        
        requireListedServer = iniparser_getint(dict, "mode1:requirelistedserver", 0);        
        if (requireListedServer == 1) {
            //Allowed servers
            for(ii = 0; ii < SERVERS_LIST_SIZE; ii++) {
                snprintf(tmpBuf, MY_TMP_BUF_LEN, "%s%d", "mode1:srvListAllow", ii);
                
                strlcpy(tmpBuf2, iniparser_getstring(dict, tmpBuf, "255.255.255.255"), MY_TMP_BUF_LEN);
                
                srvListAllow[ii] = getAddrPartsFromString(tmpBuf2);
            }


            //Denied servers
            for(ii = 0; ii < SERVERS_LIST_SIZE; ii++) {
                snprintf(tmpBuf, MY_TMP_BUF_LEN, "%s%d", "mode1:srvListDeny", ii);
                
                strlcpy(tmpBuf2, iniparser_getstring(dict, tmpBuf, "255.255.255.255"), MY_TMP_BUF_LEN);
                
                srvListDeny[ii] = getAddrPartsFromString(tmpBuf2);
            }
        }
        
        
        //Mode 2 settings
        //Mode 2 settings
        requireListedId = iniparser_getint(dict, "mode2:requirelistedid", 0);        
        if (requireListedId == 1) {
            for(ii = 0; ii < ID_LIST_SIZE; ii++) {
                snprintf(tmpBuf, MY_TMP_BUF_LEN, "%s%d", "mode2:idlist", ii);
                idList[ii] = iniparser_getint(dict, tmpBuf, 0);
            }
        }
       
        //Event interface settings
        //Event interface settings
        useEventInterface = (bool) iniparser_getboolean(dict, "eventinterface:useeventinterface", 0);     

        strlcpy(eventListenerHost, iniparser_getstring(dict, 
            "eventinterface:eventlistenerhost", "localhost"), MY_TMP_BUF_LEN);

        eventListenerPort = iniparser_getint(dict, "eventinterface:eventlistenerport", 2002);     
        
        useHttpForEventListener = (bool) iniparser_getboolean(dict,"eventinterface:usehttp", 0);     
        
        iniparser_free(dict);
        return true;           
    }
    else 
        return false;
        
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
callq 0x5fce
movq %rax, %rbx
testq %rax, %rax
je 0x66b9
leaq 0x2f90(%rip), %rsi      # 0x9349
movq %rbx, %rdi
movl $0x170c, %edx           # imm = 0x170C
callq 0x5c46
movl %eax, 0x5e24(%rip)      # 0xc1f0
leaq 0x2f89(%rip), %rsi      # 0x935c
movq %rbx, %rdi
movl $0x157c, %edx           # imm = 0x157C
callq 0x5c46
movl %eax, 0x5e0e(%rip)      # 0xc1f4
leaq 0x2f82(%rip), %rsi      # 0x936f
movl $0x64, %ebp
movq %rbx, %rdi
movl $0x64, %edx
callq 0x5c46
cmpl $0x3e9, %eax            # imm = 0x3E9
cmovgel %ebp, %eax
testl %eax, %eax
cmovlel %ebp, %eax
movl %eax, 0x662e(%rip)      # 0xca40
leaq 0x2f6a(%rip), %rsi      # 0x9383
movq %rbx, %rdi
movl $0x3, %edx
callq 0x5c46
movl %eax, 0x5dcc(%rip)      # 0xc1f8
leaq 0x2f65(%rip), %rsi      # 0x9398
leaq 0x2f73(%rip), %rdx      # 0x93ad
movq %rbx, %rdi
callq 0x5b43
leaq 0x5eb7(%rip), %rdi      # 0xc300
movl $0xff, %edx
movq %rax, %rsi
callq 0x5804
leaq 0x2f58(%rip), %rsi      # 0x93b5
leaq 0x2f63(%rip), %rdx      # 0x93c7
movq %rbx, %rdi
callq 0x5b43
leaq 0x5d8d(%rip), %rdi      # 0xc200
movl $0xff, %edx
movq %rax, %rsi
callq 0x5804
leaq 0x2f48(%rip), %rsi      # 0x93cf
movl $0x2, %ebp
movq %rbx, %rdi
movl $0x2, %edx
callq 0x5c46
cmpl $0x4, %eax
cmovgel %ebp, %eax
testl %eax, %eax
cmovsl %ebp, %eax
movl %eax, 0x659a(%rip)      # 0xca44
leaq 0x2f33(%rip), %rsi      # 0x93e4
movq %rbx, %rdi
xorl %edx, %edx
callq 0x5c46
movl %eax, 0xec5f(%rip)      # 0x15120
leaq 0x2f39(%rip), %rsi      # 0x9401
movq %rbx, %rdi
xorl %edx, %edx
callq 0x5c46
movl %eax, 0xede8(%rip)      # 0x152c0
cmpl $0x1, %eax
jne 0x65cd
leaq 0x5f20(%rip), %r15      # 0xc408
movq %rsp, %r12
leaq 0x2f41(%rip), %r13      # 0x9433
leaq 0x100(%rsp), %rbp
xorl %r14d, %r14d
movl $0xff, %esi
movq %r12, %rdi
leaq 0x2f0f(%rip), %rdx      # 0x941b
leaq 0x2f0d(%rip), %rcx      # 0x9420
movl %r14d, %r8d
xorl %eax, %eax
callq 0x2310
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x5b43
movl $0xff, %edx
movq %rbp, %rdi
movq %rax, %rsi
callq 0x5804
movq %rbp, %rdi
callq 0x66d4
movq %rax, -0x8(%r15)
movq %rdx, (%r15)
incq %r14
addq $0x10, %r15
cmpq $0x32, %r14
jne 0x64fd
leaq 0x61ca(%rip), %r15      # 0xc728
movq %rsp, %r12
leaq 0x2ecb(%rip), %r13      # 0x9433
leaq 0x100(%rsp), %rbp
xorl %r14d, %r14d
movl $0xff, %esi
movq %r12, %rdi
leaq 0x2e99(%rip), %rdx      # 0x941b
leaq 0x2eba(%rip), %rcx      # 0x9443
movl %r14d, %r8d
xorl %eax, %eax
callq 0x2310
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x5b43
movl $0xff, %edx
movq %rbp, %rdi
movq %rax, %rsi
callq 0x5804
movq %rbp, %rdi
callq 0x66d4
movq %rax, -0x8(%r15)
movq %rdx, (%r15)
incq %r14
addq $0x10, %r15
cmpq $0x32, %r14
jne 0x6573
leaq 0x2e81(%rip), %rsi      # 0x9455
movq %rbx, %rdi
xorl %edx, %edx
callq 0x5c46
movl %eax, 0xeb40(%rip)      # 0x15124
cmpl $0x1, %eax
jne 0x6639
leaq 0xeb40(%rip), %rbp      # 0x15130
leaq 0x2e24(%rip), %r14      # 0x941b
leaq 0x2e6d(%rip), %r15      # 0x946b
movq %rsp, %r12
xorl %r13d, %r13d
movl $0xff, %esi
movq %r12, %rdi
movq %r14, %rdx
movq %r15, %rcx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x2310
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x5c46
movl %eax, (%rbp)
incq %r13
addq $0x4, %rbp
cmpq $0x64, %r13
jne 0x6604
leaq 0x2e38(%rip), %rsi      # 0x9478
movq %rbx, %rdi
xorl %edx, %edx
callq 0x5c90
testl %eax, %eax
setne 0xec71(%rip)            # 0x152c4
leaq 0x2e3f(%rip), %rsi      # 0x9499
leaq 0x2e59(%rip), %rdx      # 0x94ba
movq %rbx, %rdi
callq 0x5b43
leaq 0x63e0(%rip), %rdi      # 0xca50
movl $0xff, %edx
movq %rax, %rsi
callq 0x5804
leaq 0x2e40(%rip), %rsi      # 0x94c4
movq %rbx, %rdi
movl $0x7d2, %edx            # imm = 0x7D2
callq 0x5c46
movl %eax, 0x64b9(%rip)      # 0xcb50
leaq 0x2e47(%rip), %rsi      # 0x94e5
movq %rbx, %rdi
xorl %edx, %edx
callq 0x5c90
testl %eax, %eax
setne 0xec14(%rip)            # 0x152c5
movq %rbx, %rdi
callq 0x62d7
testq %rbx, %rbx
setne %al
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)