
//#include "x/Version.h"
//#include "x/scolplugin.h"
#include "osversion.h"



// static value corresponding to the os information
osinfo theOsInfo;


// set osinfo
osinfo SetOsInfo(osinfo ver)
{
    theOsInfo = ver;
	return theOsInfo;
}

// retrieve OsInfo
osinfo GetOsInfo()
{
    
#if VERSIONPC
    
    OSVERSIONINFO stOSVI ;
    DWORD vID, minV, majV;
    
    if (theOsInfo!=kOsInfoUnknown)
        return theOsInfo;
    

    memset ( &stOSVI , 0 , sizeof ( OSVERSIONINFO ) );
    stOSVI.dwOSVersionInfoSize = sizeof ( OSVERSIONINFO );
    if (!GetVersionEx(&stOSVI))
        return SetOsInfo(kOsInfoWinUnknown);
    
    vID  = stOSVI.dwPlatformId;
    minV = stOSVI.dwMinorVersion;
    majV = stOSVI.dwMajorVersion;
    
    
    if (vID == VER_PLATFORM_WIN32_WINDOWS)
    {
        if ((majV == 4) && (minV == 0))
            return SetOsInfo (kOsInfoWin95);
        
        if ((majV == 4) && (minV == 10))
            return SetOsInfo (kOsInfoWin98);
        
        if ((majV == 4) && (minV == 90))
            return SetOsInfo (kOsInfoWinMe);
    }
    else
        if (vID == VER_PLATFORM_WIN32_NT)
        {
            if ((majV == 4) && (minV == 0))
                return SetOsInfo (kOsInfoWinNT4);
            
            if ((majV == 5) && (minV == 0))
                return SetOsInfo (kOsInfoWin2000);
            
            if ((majV == 5) && (minV == 1))
                return SetOsInfo (kOsInfoWinXp);
        }
    return SetOsInfo(kOsInfoWinUnknown);

#else

    return SetOsInfo (kOsInfoUnknown);

#endif        

}
