Raised This Month: $51 Target: $400
 12% 

The operating system of server


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
gubka
Veteran Member
Join Date: Jan 2012
Location: Russia
Old 08-11-2018 , 13:23   The operating system of server
Reply With Quote #1

PHP Code:
/**
 * List of operation systems.
 **/
enum EngineOS
{
    
OS_Unknown,
    
OS_Windows,
    
OS_Linux,
    
OS_Mac
};

EngineOS Server_PlatForm;

/**
 * Gets the server operating system.
 *
 * @param oS                The platform id.
 *
 * @return                  True or false.
 **/
bool GameEnginePlatform(EngineOS oS)
{
    
// Validate platform
    
if(Server_PlatForm == OS_Unknown)
    {
        
// Initialize char
        
char sBuffer[PLATFORM_MAX_PATH+PLATFORM_MAX_PATH];
        
        
// Extract status string
        
ServerCommandEx(sBuffersizeof(sBuffer), "status");

        
// Precompile a regular expression
        
Regex hRegex CompileRegex("(os\\s+:\\s+\\w+)"); 
        
        
// i = str index
        
int iCount hRegex.Match(sBuffer); 
        for(
int i 0iCounti++) 
        { 
            
// Returns a matched substring from a regex handle
            
hRegex.GetSubString(isBuffersizeof(sBuffer)); 
            
            
// Finds the first occurrence of a character in a string
            
int iSystem FindCharInString(sBuffer' 'true) + 1;

            
// Validate operating system
            
Server_PlatForm = !strncmp(sBuffer[iSystem], "win"3false) ? OS_Windows : !strncmp(sBuffer[iSystem], "lin"3false) ? OS_Linux OS_Mac;
            break;
        }
        
        
// Decompile expression
        
delete hRegex;
    }
    
    
// Return on success
    
return (Server_PlatForm == oS);

__________________
gubka is offline
Send a message via ICQ to gubka
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:03.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode