// File: /workspace/github_c_makefile_star2_O0/schroeder-lvb[P]sissm/src/piwebgen.c
// Function: genWebFile
static int _genWebFile( void )
{
    FILE *fpw;
    char *w;
    int   errCode = 1;
    int   i;
    char  *printWordOut, *rosterElem, rosterElem2[1024];
    char  rosterWork[PIWEBGEN_MAXROSTER];
    char  hyperLinkCode[256];
    char  timeoutStatus[256];
    char  *srvName;

    if (NULL != (fpw = fopen( piwebgenConfig.webFileName, "wt" ))) {

        if ( apiTimeGet() < (piwebgenConfig.commTimeoutSec + apiGetLastRosterTime()) )   {
            strlcpy( timeoutStatus, "[OK]", 256 );
            w = rosterGetObjective();
            if ( 0 != strlen( w ) ) strlcpy( timeoutStatus, w, 256 );
        }
        else
            strlcpy( timeoutStatus, "<font color=\"red\">[SERVER DOWN]</font> ", 256 );

        // Option for creating auto-refresh header for html.  Turn this off if you are refreshing
        // from higher level (e.g., text file inclusion or html frames).
        //
	if ( 0 != piwebgenConfig.autoRefreshHeader ) {
            fprintf( fpw, "<meta http-equiv=\"refresh\" content=\"14\" /> \n" );
        }

        // Option for UTF-8 encoding extended character sets
        //
	if ( 0 != piwebgenConfig.utf8Encoding ) {
            fprintf( fpw, "<meta charset=\"utf-8\"> \n" );
        }

        // Displaying the server name - from sissm.cfg file, or RCON
        //
        srvName = apiGetServerName();
        if ( 0 == strncmp( srvName, "*", 2 ) ) 
            srvName = apiGetServerNameRCON( 0 );
        fprintf( fpw, "<b>%s</b>\n", srvName );

        // Option for displaying extra line description
        //
        if ( 0 != strlen( piwebgenConfig.line2 ) )
            fprintf( fpw, "<br>%s\n", piwebgenConfig.line2 );

        // Option for displaying current sessino ID for playbacks
        //
        if ( piwebgenConfig.showSessionID )
            fprintf( fpw, "<br>SID: %s\n", apiGetSessionID());

        // Display map & lighting mode
        //
        fprintf( fpw, "<br>Map: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp %s (%s)\n", apiGetMapName(), apiGetLighting() );

        // Display number of players and stauts of the server
        //
        fprintf( fpw, "<br>Players: &nbsp; %d  &nbsp;&nbsp;&nbsp; Status: &nbsp;&nbsp;  %s\n", 
            apiPlayersGetCount(), timeoutStatus);

        // Option for displaying "current time" 
        //
        if ( piwebgenConfig.showCurrentTime ) {
            fprintf( fpw, "<br>Time: &nbsp;&nbsp;&nbsp;&nbsp;   %s [Now]\n", apiTimeGetHuman(0L) );
        }
 
        // Option for displaying "last reboot event & last reboot time"
        //
        if ( piwebgenConfig.showLastReboot ) {
            fprintf( fpw, "<br>Last: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   %s [%s]\n", 
                apiTimeGetHuman( apiGetLastRebootTime()), apiGetLastRebootReason() );
        }

        // Option for displaying "last reboot event & elapsed time since reboot"
        //
        if ( piwebgenConfig.showUpTime ) {
            fprintf( fpw, "<br>Uptime: &nbsp; %s since [%s]\n", 
                computeElapsedTime( apiGetLastRebootTime(), apiTimeGet()), apiGetLastRebootReason() );
        }

        // Option for displaying direct IP connection method from game client
        //
        if ( 0 != strlen( piwebgenConfig.directConnect ) )
            fprintf( fpw, "<br>Connect: %s\n", piwebgenConfig.directConnect );

        // Option for displaying hyperlink to web-based admin page
        //
        if ( 0 != strlen( piwebgenConfig.webminURL ) )  {
            snprintf( hyperLinkCode, 256, "<a href=\"%s\" target=\"_blank\">link</a>", 
                piwebgenConfig.webminURL );
            fprintf( fpw, "<br>Admin: &nbsp;&nbsp; %s\n", hyperLinkCode );
        }

        if ( 0 != piwebgenConfig.showGameMode ) {
            fprintf( fpw, "<br>Game Mode: &nbsp;&nbsp;   %s\n", gameMode );
        }

        if ( 0 != piwebgenConfig.showMutators ) {
            fprintf( fpw, "<br>Mutators: &nbsp;&nbsp;&nbsp;   %s\n", gameMutators );
        }

        switch( p2pGetL( "pigateway.p2p.lockOut", 0L )) {
        case 1L:
            fprintf( fpw, "<br>* Temporarily LOCKED for Private Session *\n" );
            break;
        case 2L:
            fprintf( fpw, "<br>*** Server LOCKED for Private Sessions ***\n" );
            break;
        case 3L:
            fprintf( fpw, "<br>*** Server RESERVED for Private Group ***\n" );
            break;
        }

        // Display list of players
        //
        fprintf( fpw, "<br>Names: &nbsp;&nbsp; ");
	if ( 0 == piwebgenConfig.hyperlinkFormat ) {
            fprintf( fpw, "<font color=\"blue\">%s</font> ", apiPlayersRoster( 0, " : " ) );
	}
	else {
            // get roster with tab for delimiter
	    strlcpy( rosterWork,  _htmlSafeFilter( apiPlayersRoster( 4, "\011" )), PIWEBGEN_MAXROSTER);  
	    if (  0 != strlen( rosterWork )) {                   // if not an empty list then
 	        for ( i=0 ;; i++ ) {

		    // walk through each player
		    //
                    strclr( rosterElem2 );
		    rosterElem = getWord( rosterWork, i, "\011" );  
		    if (NULL == rosterElem)        break;    // end of list?
		    if (strlen( rosterElem) < 35 ) break;    // element is invalid if <35 chars

                    strlcpy( rosterElem2, rosterElem, 1024 );

		    // convert each player record to hyperlink html format
		    //
                    printWordOut = _convertNameToHyperlink( rosterElem2 );

		    // write out this player info  to the html file
		    //
                    fprintf( fpw, "%s ", printWordOut );
                }
	    }
	}
        fprintf( fpw, "\n<br><br>\n");
        fclose( fpw );
        errCode = 0;
    }
    else {
        logPrintf( LOG_LEVEL_CRITICAL,
            "piwebstat", "Unable to create the html output file ::%s::",
            piwebgenConfig.webFileName );
    }
    return errCode;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x46b0, %rsp           # imm = 0x46B0
movl $0x1, -0x14(%rbp)
leaq 0xc0777(%rip), %rdi     # 0xd42c0
addq $0x8, %rdi
leaq 0x11fa0(%rip), %rsi     # 0x25af4
callq 0x8310
movq %rax, %rcx
movq %rcx, -0x8(%rbp)
xorl %eax, %eax
cmpq %rcx, %rax
je 0x140ee
callq 0x150c0
movq %rax, -0x4640(%rbp)
movslq 0xc13da(%rip), %rax     # 0xd4f58
movq %rax, -0x4648(%rbp)
callq 0x14ca0
movq -0x4648(%rbp), %rcx
movq %rax, %rdx
movq -0x4640(%rbp), %rax
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x13bee
leaq -0x4630(%rbp), %rdi
leaq 0x11f9a(%rip), %rsi     # 0x25b4b
movl $0x100, %edx            # imm = 0x100
callq 0x11bc0
callq 0x193c0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8110
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
je 0x13bec
leaq -0x4630(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x11bc0
jmp 0x13c06
leaq -0x4630(%rbp), %rdi
leaq 0x11f54(%rip), %rsi     # 0x25b50
movl $0x100, %edx            # imm = 0x100
callq 0x11bc0
xorl %eax, %eax
cmpl 0xc1346(%rip), %eax     # 0xd4f54
je 0x13c22
movq -0x8(%rbp), %rdi
leaq 0x11edc(%rip), %rsi     # 0x25af7
movb $0x0, %al
callq 0x8230
xorl %eax, %eax
cmpl 0xc069a(%rip), %eax     # 0xd42c4
je 0x13c3e
movq -0x8(%rbp), %rdi
leaq 0x11f41(%rip), %rsi     # 0x25b78
movb $0x0, %al
callq 0x8230
callq 0x182e0
movq %rax, -0x4638(%rbp)
movq -0x4638(%rbp), %rdi
leaq 0xffa4(%rip), %rsi      # 0x23bfc
movl $0x2, %edx
callq 0x8060
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x13c78
xorl %edi, %edi
callq 0x151a0
movq %rax, -0x4638(%rbp)
movq -0x8(%rbp), %rdi
movq -0x4638(%rbp), %rdx
leaq 0x11f07(%rip), %rsi     # 0x25b91
movb $0x0, %al
callq 0x8230
leaq 0xc0eb8(%rip), %rdi     # 0xd4b50
callq 0x8110
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
je 0x13cc7
movq -0x8(%rbp), %rdi
leaq 0x11eea(%rip), %rsi     # 0x25b9c
leaq 0xc0607(%rip), %rdx     # 0xd42c0
addq $0x890, %rdx            # imm = 0x890
movb $0x0, %al
callq 0x8230
cmpl $0x0, 0xc128e(%rip)     # 0xd4f5c
je 0x13cf8
movq -0x8(%rbp), %rax
movq %rax, -0x4650(%rbp)
callq 0x18310
movq -0x4650(%rbp), %rdi
movq %rax, %rdx
leaq 0x11eb3(%rip), %rsi     # 0x25ba4
movb $0x0, %al
callq 0x8230
movq -0x8(%rbp), %rax
movq %rax, -0x4668(%rbp)
callq 0x182f0
movq %rax, -0x4660(%rbp)
callq 0x18300
movq -0x4668(%rbp), %rdi
movq -0x4660(%rbp), %rdx
movq %rax, %rcx
leaq 0x11e85(%rip), %rsi     # 0x25bb1
movb $0x0, %al
callq 0x8230
movq -0x8(%rbp), %rax
movq %rax, -0x4658(%rbp)
callq 0x17fe0
movq -0x4658(%rbp), %rdi
movl %eax, %edx
leaq -0x4630(%rbp), %rcx
leaq 0x11e87(%rip), %rsi     # 0x25be1
movb $0x0, %al
callq 0x8230
cmpl $0x0, 0xc1204(%rip)     # 0xd4f6c
je 0x13d96
movq -0x8(%rbp), %rax
movq %rax, -0x4670(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x17620
movq -0x4670(%rbp), %rdi
movq %rax, %rdx
leaq 0x11e97(%rip), %rsi     # 0x25c26
movb $0x0, %al
callq 0x8230
cmpl $0x0, 0xc11cb(%rip)     # 0xd4f68
je 0x13de2
movq -0x8(%rbp), %rax
movq %rax, -0x4680(%rbp)
callq 0x174f0
movq %rax, %rdi
callq 0x17620
movq %rax, -0x4678(%rbp)
callq 0x17500
movq -0x4680(%rbp), %rdi
movq -0x4678(%rbp), %rdx
movq %rax, %rcx
leaq 0x11e7a(%rip), %rsi     # 0x25c55
movb $0x0, %al
callq 0x8230
cmpl $0x0, 0xc117b(%rip)     # 0xd4f64
je 0x13e41
movq -0x8(%rbp), %rax
movq %rax, -0x4690(%rbp)
callq 0x174f0
movq %rax, -0x4698(%rbp)
callq 0x150c0
movq -0x4698(%rbp), %rdi
movq %rax, %rsi
callq 0x121f0
movq %rax, -0x4688(%rbp)
callq 0x17500
movq -0x4690(%rbp), %rdi
movq -0x4688(%rbp), %rdx
movq %rax, %rcx
leaq 0x11e4f(%rip), %rsi     # 0x25c89
movb $0x0, %al
callq 0x8230
leaq 0xc0908(%rip), %rdi     # 0xd4750
callq 0x8110
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
je 0x13e77
movq -0x8(%rbp), %rdi
leaq 0x11e49(%rip), %rsi     # 0x25cab
leaq 0xc0457(%rip), %rdx     # 0xd42c0
addq $0x490, %rdx            # imm = 0x490
movb $0x0, %al
callq 0x8230
leaq 0xc0852(%rip), %rdi     # 0xd46d0
callq 0x8110
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
je 0x13ece
leaq -0x4530(%rbp), %rdi
movl $0x100, %esi            # imm = 0x100
leaq 0x11e1c(%rip), %rdx     # 0x25cbc
leaq 0xc0419(%rip), %rcx     # 0xd42c0
addq $0x410, %rcx            # imm = 0x410
movb $0x0, %al
callq 0x8180
movq -0x8(%rbp), %rdi
leaq -0x4530(%rbp), %rdx
leaq 0x11e1b(%rip), %rsi     # 0x25ce2
movb $0x0, %al
callq 0x8230
xorl %eax, %eax
cmpl 0xc109a(%rip), %eax     # 0xd4f70
je 0x13ef1
movq -0x8(%rbp), %rdi
leaq 0x11e1b(%rip), %rsi     # 0x25cfe
leaq 0xc1096(%rip), %rdx     # 0xd4f80
movb $0x0, %al
callq 0x8230
xorl %eax, %eax
cmpl 0xc107b(%rip), %eax     # 0xd4f74
je 0x13f14
movq -0x8(%rbp), %rdi
leaq 0x11e1a(%rip), %rsi     # 0x25d20
leaq 0xc1173(%rip), %rdx     # 0xd5080
movb $0x0, %al
callq 0x8230
leaq 0xf86b(%rip), %rdi      # 0x23786
xorl %eax, %eax
movl %eax, %esi
callq 0x1eda0
movq %rax, %rcx
movq %rcx, -0x46a0(%rbp)
subq $0x1, %rax
je 0x13f54
jmp 0x13f36
movq -0x46a0(%rbp), %rax
subq $0x2, %rax
je 0x13f68
jmp 0x13f45
movq -0x46a0(%rbp), %rax
subq $0x3, %rax
je 0x13f7c
jmp 0x13f8e
movq -0x8(%rbp), %rdi
leaq 0x11de8(%rip), %rsi     # 0x25d47
movb $0x0, %al
callq 0x8230
jmp 0x13f8e
movq -0x8(%rbp), %rdi
leaq 0x11e04(%rip), %rsi     # 0x25d77
movb $0x0, %al
callq 0x8230
jmp 0x13f8e
movq -0x8(%rbp), %rdi
leaq 0x11e20(%rip), %rsi     # 0x25da7
movb $0x0, %al
callq 0x8230
movq -0x8(%rbp), %rdi
leaq 0x11e3d(%rip), %rsi     # 0x25dd6
movb $0x0, %al
callq 0x8230
xorl %eax, %eax
cmpl 0xc0fa8(%rip), %eax     # 0xd4f50
jne 0x13fe0
movq -0x8(%rbp), %rax
movq %rax, -0x46a8(%rbp)
xorl %edi, %edi
leaq 0x11e4f(%rip), %rsi     # 0x25e0d
callq 0x17ff0
movq -0x46a8(%rbp), %rdi
movq %rax, %rdx
leaq 0x11e1b(%rip), %rsi     # 0x25def
movb $0x0, %al
callq 0x8230
jmp 0x140ca
leaq -0x4430(%rbp), %rax
movq %rax, -0x46b0(%rbp)
movl $0x4, %edi
leaq 0x12a5c(%rip), %rsi     # 0x26a56
callq 0x17ff0
movq %rax, %rdi
callq 0x139a0
movq -0x46b0(%rbp), %rdi
movq %rax, %rsi
movl $0x4000, %edx           # imm = 0x4000
callq 0x11bc0
leaq -0x4430(%rbp), %rdi
callq 0x8110
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
je 0x140c8
movl $0x0, -0x18(%rbp)
leaq -0x430(%rbp), %rdi
callq 0x122b0
leaq -0x4430(%rbp), %rdi
movl -0x18(%rbp), %esi
leaq 0x129fd(%rip), %rdx     # 0x26a56
callq 0x122d0
movq %rax, -0x28(%rbp)
xorl %eax, %eax
cmpq -0x28(%rbp), %rax
jne 0x1406c
jmp 0x140c6
movq -0x28(%rbp), %rdi
callq 0x8110
cmpq $0x23, %rax
jae 0x1407d
jmp 0x140c6
leaq -0x430(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x11bc0
leaq -0x430(%rbp), %rdi
callq 0x137f0
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0x11d60(%rip), %rsi     # 0x25e11
movb $0x0, %al
callq 0x8230
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1403c
jmp 0x140c8
jmp 0x140ca
movq -0x8(%rbp), %rdi
leaq 0x11d40(%rip), %rsi     # 0x25e15
movb $0x0, %al
callq 0x8230
movq -0x8(%rbp), %rdi
callq 0x80f0
movl $0x0, -0x14(%rbp)
jmp 0x14110
xorl %edi, %edi
leaq 0x11d29(%rip), %rsi     # 0x25e20
leaq 0x11d2c(%rip), %rdx     # 0x25e2a
leaq 0xc01bb(%rip), %rcx     # 0xd42c0
addq $0x8, %rcx
movb $0x0, %al
callq 0x21bf0
movl -0x14(%rbp), %eax
addq $0x46b0, %rsp           # imm = 0x46B0
popq %rbp
retq
nopl (%rax)