// File: /workspace/github_c_makefile_star2_O1/schroeder-lvb[P]sissm/src/pirebooter.c
// Function: pirebooterInitConfig
int pirebooterInitConfig( void )
{
    cfsPtr cP;

    cP = cfsCreate( sissmGetConfigPath() );

    // read "pirebooter.pluginstate" variable from the .cfg file
    pirebooterConfig.pluginState = (int) cfsFetchNum( cP, "pirebooter.pluginState", 0.0 );  // disabled by default
    pirebooterConfig.rebootIdleSec = (long int) cfsFetchNum( cP, "pirebooter.rebootidlesec", (double)   20*60 );
    pirebooterConfig.rebootBusySec = (long int) cfsFetchNum( cP, "pirebooter.rebootbusysec", (double) 5*60*60 );
    pirebooterConfig.rebootDeadSec = (long int) cfsFetchNum( cP, "pirebooter.rebootdeadsec", (double)    5*60 );
    pirebooterConfig.rebootHungSec = (long int) cfsFetchNum( cP, "pirebooter.reboothungsec", (double)   20*60 );

    pirebooterConfig.rebootOnEOR   = (long int) cfsFetchNum( cP, "pirebooter.rebootoneor",   (double)       0 );

    // read the daily reboot time, e.g., "19:03".  Add colon "19:03:" so that it can be pattern
    // checked quickly against HH:MM:SS system clockstring and not get mistaken for MM:SS check.
    //
    strlcpy( pirebooterConfig.rebootDailyHM, cfsFetchStr( cP, "pirebooter.rebootDailyHM", "99:99"), CFS_FETCH_MAX );
    if ( 5 == strlen( pirebooterConfig.rebootDailyHM )) 
        strlcat( pirebooterConfig.rebootDailyHM, ":", CFS_FETCH_MAX );
    else
        strlcat( pirebooterConfig.rebootDailyHM, "99:99:", CFS_FETCH_MAX );

    pirebooterConfig.logUpdateSec  = (int)      cfsFetchNum( cP, "pirebooter.logUpdateSec",  (double)      60 );

    strlcpy( pirebooterConfig.rebootWarning, 
        cfsFetchStr( cP, "pirebooter.rebootWarning", "Server restart at end of round - up in 60sec" ), CFS_FETCH_MAX);
    strlcpy( pirebooterConfig.rebootDaily, 
        cfsFetchStr( cP, "pirebooter.rebootDaily", "** Server will reboot shortly - up in 60sec" ), CFS_FETCH_MAX);

    cfsDestroy( cP );
    
    pirebooterConfig.timeLastReboot = apiTimeGet();
    pirebooterConfig.timeLastProgress = apiTimeGet();
    pirebooterConfig.timeFirstIdle  = 0;

    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
callq 0x8969
movq %rax, %rdi
callq 0x9004
movq %rax, %rbx
leaq 0xf89d(%rip), %rsi      # 0x1cb38
xorpd %xmm0, %xmm0
movq %rax, %rdi
callq 0x9276
cvttsd2si %xmm0, %eax
movl %eax, 0x6e1cf(%rip)     # 0x7b480
leaq 0xf897(%rip), %rsi      # 0x1cb4f
movsd 0xf858(%rip), %xmm0     # 0x1cb18
movq %rbx, %rdi
callq 0x9276
cvttsd2si %xmm0, %rax
movq %rax, 0x6e1b4(%rip)     # 0x7b488
leaq 0xf88d(%rip), %rsi      # 0x1cb68
movsd 0xf83d(%rip), %xmm0     # 0x1cb20
movq %rbx, %rdi
callq 0x9276
cvttsd2si %xmm0, %rax
movq %rax, 0x6e199(%rip)     # 0x7b490
leaq 0xf883(%rip), %rsi      # 0x1cb81
movsd 0xf822(%rip), %xmm0     # 0x1cb28
movq %rbx, %rdi
callq 0x9276
cvttsd2si %xmm0, %rax
movq %rax, 0x6e17e(%rip)     # 0x7b498
leaq 0xf879(%rip), %rsi      # 0x1cb9a
movq %rbx, %rdi
movsd 0xf7ec(%rip), %xmm0     # 0x1cb18
callq 0x9276
cvttsd2si %xmm0, %rax
movq %rax, 0x6e163(%rip)     # 0x7b4a0
leaq 0xf86f(%rip), %rsi      # 0x1cbb3
xorpd %xmm0, %xmm0
movq %rbx, %rdi
callq 0x9276
cvttsd2si %xmm0, %rax
movq %rax, 0x6e54c(%rip)     # 0x7b8a8
leaq 0xf867(%rip), %rsi      # 0x1cbca
leaq 0xf879(%rip), %rdx      # 0x1cbe3
movq %rbx, %rdi
callq 0x907b
leaq 0x6e12f(%rip), %r14     # 0x7b4a8
movl $0x400, %edx            # imm = 0x400
movq %r14, %rdi
movq %rax, %rsi
callq 0xf038
movq %r14, %rdi
callq 0x8120
cmpq $0x5, %rax
leaq 0x10af1(%rip), %rax     # 0x1de8d
leaq 0xf846(%rip), %rsi      # 0x1cbe9
cmoveq %rax, %rsi
movl $0x400, %edx            # imm = 0x400
movq %r14, %rdi
callq 0xefc4
leaq 0xf835(%rip), %rsi      # 0x1cbf0
movsd 0xf76d(%rip), %xmm0     # 0x1cb30
movq %rbx, %rdi
callq 0x9276
cvttsd2si %xmm0, %eax
movl %eax, 0x6e0af(%rip)     # 0x7b484
leaq 0xf82c(%rip), %rsi      # 0x1cc08
leaq 0xf83e(%rip), %rdx      # 0x1cc21
movq %rbx, %rdi
callq 0x907b
leaq 0x6e4d6(%rip), %rdi     # 0x7b8c8
movl $0x400, %edx            # imm = 0x400
movq %rax, %rsi
callq 0xf038
leaq 0xf848(%rip), %rsi      # 0x1cc4e
leaq 0xf858(%rip), %rdx      # 0x1cc65
movq %rbx, %rdi
callq 0x907b
leaq 0x6e8ac(%rip), %rdi     # 0x7bcc8
movl $0x400, %edx            # imm = 0x400
movq %rax, %rsi
callq 0xf038
movq %rbx, %rdi
callq 0x905c
callq 0x114b2
movq %rax, 0x6e473(%rip)     # 0x7b8b0
callq 0x114b2
movq %rax, 0x6e477(%rip)     # 0x7b8c0
movq $0x0, 0x6e464(%rip) # 0x7b8b8
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq