// File: /workspace/github_cpp_makefile_star2_O1/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 0x604b
movq %rax, %rbx
testq %rax, %rax
je 0x6739
leaq 0x2f10(%rip), %rsi      # 0x9349
movq %rbx, %rdi
movl $0x170c, %edx           # imm = 0x170C
callq 0x5c8f
movl %eax, 0x5da4(%rip)      # 0xc1f0
leaq 0x2f09(%rip), %rsi      # 0x935c
movq %rbx, %rdi
movl $0x157c, %edx           # imm = 0x157C
callq 0x5c8f
movl %eax, 0x5d8e(%rip)      # 0xc1f4
leaq 0x2f02(%rip), %rsi      # 0x936f
movl $0x64, %ebp
movq %rbx, %rdi
movl $0x64, %edx
callq 0x5c8f
cmpl $0x3e9, %eax            # imm = 0x3E9
cmovgel %ebp, %eax
testl %eax, %eax
cmovlel %ebp, %eax
movl %eax, 0x65ae(%rip)      # 0xca40
leaq 0x2eea(%rip), %rsi      # 0x9383
movq %rbx, %rdi
movl $0x3, %edx
callq 0x5c8f
movl %eax, 0x5d4c(%rip)      # 0xc1f8
leaq 0x2ee5(%rip), %rsi      # 0x9398
leaq 0x2ef3(%rip), %rdx      # 0x93ad
movq %rbx, %rdi
callq 0x5b8c
leaq 0x5e37(%rip), %rdi      # 0xc300
movl $0xff, %edx
movq %rax, %rsi
callq 0x5844
leaq 0x2ed8(%rip), %rsi      # 0x93b5
leaq 0x2ee3(%rip), %rdx      # 0x93c7
movq %rbx, %rdi
callq 0x5b8c
leaq 0x5d0d(%rip), %rdi      # 0xc200
movl $0xff, %edx
movq %rax, %rsi
callq 0x5844
leaq 0x2ec8(%rip), %rsi      # 0x93cf
movl $0x2, %ebp
movq %rbx, %rdi
movl $0x2, %edx
callq 0x5c8f
cmpl $0x4, %eax
cmovgel %ebp, %eax
testl %eax, %eax
cmovsl %ebp, %eax
movl %eax, 0x651a(%rip)      # 0xca44
leaq 0x2eb3(%rip), %rsi      # 0x93e4
movq %rbx, %rdi
xorl %edx, %edx
callq 0x5c8f
movl %eax, 0xebdf(%rip)      # 0x15120
leaq 0x2eb9(%rip), %rsi      # 0x9401
movq %rbx, %rdi
xorl %edx, %edx
callq 0x5c8f
movl %eax, 0xed68(%rip)      # 0x152c0
cmpl $0x1, %eax
jne 0x664d
leaq 0x5ea0(%rip), %r15      # 0xc408
movq %rsp, %r12
leaq 0x2ec1(%rip), %r13      # 0x9433
leaq 0x100(%rsp), %rbp
xorl %r14d, %r14d
movl $0xff, %esi
movq %r12, %rdi
leaq 0x2e8f(%rip), %rdx      # 0x941b
leaq 0x2e8d(%rip), %rcx      # 0x9420
movl %r14d, %r8d
xorl %eax, %eax
callq 0x2310
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x5b8c
movl $0xff, %edx
movq %rbp, %rdi
movq %rax, %rsi
callq 0x5844
movq %rbp, %rdi
callq 0x6754
movq %rax, -0x8(%r15)
movq %rdx, (%r15)
incq %r14
addq $0x10, %r15
cmpq $0x32, %r14
jne 0x657d
leaq 0x614a(%rip), %r15      # 0xc728
movq %rsp, %r12
leaq 0x2e4b(%rip), %r13      # 0x9433
leaq 0x100(%rsp), %rbp
xorl %r14d, %r14d
movl $0xff, %esi
movq %r12, %rdi
leaq 0x2e19(%rip), %rdx      # 0x941b
leaq 0x2e3a(%rip), %rcx      # 0x9443
movl %r14d, %r8d
xorl %eax, %eax
callq 0x2310
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x5b8c
movl $0xff, %edx
movq %rbp, %rdi
movq %rax, %rsi
callq 0x5844
movq %rbp, %rdi
callq 0x6754
movq %rax, -0x8(%r15)
movq %rdx, (%r15)
incq %r14
addq $0x10, %r15
cmpq $0x32, %r14
jne 0x65f3
leaq 0x2e01(%rip), %rsi      # 0x9455
movq %rbx, %rdi
xorl %edx, %edx
callq 0x5c8f
movl %eax, 0xeac0(%rip)      # 0x15124
cmpl $0x1, %eax
jne 0x66b9
leaq 0xeac0(%rip), %rbp      # 0x15130
leaq 0x2da4(%rip), %r14      # 0x941b
leaq 0x2ded(%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 0x5c8f
movl %eax, (%rbp)
incq %r13
addq $0x4, %rbp
cmpq $0x64, %r13
jne 0x6684
leaq 0x2db8(%rip), %rsi      # 0x9478
movq %rbx, %rdi
xorl %edx, %edx
callq 0x5cd9
testl %eax, %eax
setne 0xebf1(%rip)            # 0x152c4
leaq 0x2dbf(%rip), %rsi      # 0x9499
leaq 0x2dd9(%rip), %rdx      # 0x94ba
movq %rbx, %rdi
callq 0x5b8c
leaq 0x6360(%rip), %rdi      # 0xca50
movl $0xff, %edx
movq %rax, %rsi
callq 0x5844
leaq 0x2dc0(%rip), %rsi      # 0x94c4
movq %rbx, %rdi
movl $0x7d2, %edx            # imm = 0x7D2
callq 0x5c8f
movl %eax, 0x6439(%rip)      # 0xcb50
leaq 0x2dc7(%rip), %rsi      # 0x94e5
movq %rbx, %rdi
xorl %edx, %edx
callq 0x5cd9
testl %eax, %eax
setne 0xeb94(%rip)            # 0x152c5
movq %rbx, %rdi
callq 0x6354
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)