ReactOS  0.4.14-dev-1256-g2125fec
CConfiguration Class Reference

#include <CConfiguration.h>

Public Member Functions

 CConfiguration ()
 
void ParseParameters (int argc, wchar_t *argv[])
 
void GetSystemInformation ()
 
void GetConfigurationFromFile ()
 
bool DoCrashRecovery () const
 
bool DoPrint () const
 
bool DoShutdown () const
 
bool DoSubmit () const
 
bool IsInteractive () const
 
bool IsReactOS () const
 
const stringGetComment () const
 
const wstring & GetModule () const
 
const stringGetTest () const
 
const stringGetAuthenticationRequestString () const
 
const stringGetSystemInfoRequestString () const
 

Private Attributes

bool m_CrashRecovery
 
bool m_IsInteractive
 
bool m_IsReactOS
 
bool m_PrintToConsole
 
bool m_Shutdown
 
bool m_Submit
 
string m_Comment
 
wstring m_Module
 
string m_Test
 
string m_AuthenticationRequestString
 
string m_SystemInfoRequestString
 

Detailed Description

Definition at line 8 of file CConfiguration.h.

Constructor & Destructor Documentation

◆ CConfiguration()

CConfiguration::CConfiguration ( )

Constructs an empty CConfiguration object

Definition at line 18 of file CConfiguration.cpp.

19  : m_CrashRecovery(false),
20  m_IsInteractive(false),
21  m_PrintToConsole(true),
22  m_Shutdown(false),
23  m_Submit(false)
24 {
25  WCHAR WindowsDirectory[MAX_PATH];
26  WCHAR Interactive[32];
27 
28  /* Check if we are running under ReactOS from the SystemRoot directory */
29  if(!GetWindowsDirectoryW(WindowsDirectory, MAX_PATH))
30  FATAL("GetWindowsDirectoryW failed\n");
31 
32  m_IsReactOS = !_wcsnicmp(&WindowsDirectory[3], L"reactos", 7);
33 
34  if(GetEnvironmentVariableW(L"WINETEST_INTERACTIVE", Interactive, _countof(Interactive)))
36 }
#define FATAL(Message)
Definition: precomp.h:57
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:26
static const WCHAR L[]
Definition: oid.c:1250
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:420

Member Function Documentation

◆ DoCrashRecovery()

bool CConfiguration::DoCrashRecovery ( ) const
inline

Definition at line 30 of file CConfiguration.h.

30 { return m_CrashRecovery; }

Referenced by CWineTest::Run().

◆ DoPrint()

bool CConfiguration::DoPrint ( ) const
inline

Definition at line 31 of file CConfiguration.h.

31 { return m_PrintToConsole; }

Referenced by StringOut().

◆ DoShutdown()

bool CConfiguration::DoShutdown ( ) const
inline

Definition at line 32 of file CConfiguration.h.

32 { return m_Shutdown; }

Referenced by wmain().

◆ DoSubmit()

bool CConfiguration::DoSubmit ( ) const
inline

Definition at line 33 of file CConfiguration.h.

33 { return m_Submit; }

Referenced by CWineTest::Run(), and CWineTest::RunTest().

◆ GetAuthenticationRequestString()

const string& CConfiguration::GetAuthenticationRequestString ( ) const
inline

◆ GetComment()

const string& CConfiguration::GetComment ( ) const
inline

Definition at line 36 of file CConfiguration.h.

36 { return m_Comment; }

Referenced by CWebService::GetTestID().

◆ GetConfigurationFromFile()

void CConfiguration::GetConfigurationFromFile ( )

Reads additional configuration options from the INI file.

ParseParameters should be called before this function to get the desired result.

Definition at line 175 of file CConfiguration.cpp.

176 {
177  DWORD Length;
178  string Value;
179  WCHAR ConfigFile[MAX_PATH];
180 
181  /* Most values are only needed if we're going to submit anything */
182  if(m_Submit)
183  {
184  /* Build the path to the configuration file from the application's path */
185  GetModuleFileNameW(NULL, ConfigFile, MAX_PATH);
186  Length = wcsrchr(ConfigFile, '\\') - ConfigFile + 1;
187  wcscpy(&ConfigFile[Length], CONFIGURATION_FILENAMEW);
188 
189  /* Check if it exists */
191  EXCEPTION("Missing \"" CONFIGURATION_FILENAMEA "\" configuration file!\n");
192 
193  /* Get the user name */
194  m_AuthenticationRequestString = "&sourceid=";
195  Value = GetINIValue(L"Login", L"SourceID", ConfigFile);
196 
197  if(Value.empty())
198  EXCEPTION("SourceID is missing in the configuration file\n");
199 
201 
202  /* Get the password */
203  m_AuthenticationRequestString += "&password=";
204  Value = GetINIValue(L"Login", L"Password", ConfigFile);
205 
206  if(Value.empty())
207  EXCEPTION("Password is missing in the configuration file\n");
208 
210 
211  /* If we don't have any Comment string yet, try to find one in the INI file */
212  if(m_Comment.empty())
213  m_Comment = GetINIValue(L"Submission", L"Comment", ConfigFile);
214  }
215 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2374
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
smooth NULL
Definition: ftsmooth.c:416
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
#define EXCEPTION(Message)
Definition: precomp.h:56
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
string EscapeString(const char *Input)
Definition: tools.cpp:24
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
string GetINIValue(PCWCH AppName, PCWCH KeyName, PCWCH FileName)
Definition: tools.cpp:187
#define CONFIGURATION_FILENAMEW
#define CONFIGURATION_FILENAMEA
string m_AuthenticationRequestString

Referenced by wmain().

◆ GetModule()

const wstring& CConfiguration::GetModule ( ) const
inline

Definition at line 37 of file CConfiguration.h.

37 { return m_Module; }

Referenced by CWineTest::GetNextFile(), and CWineTest::Run().

◆ GetSystemInfoRequestString()

const string& CConfiguration::GetSystemInfoRequestString ( ) const
inline

Definition at line 41 of file CConfiguration.h.

41 { return m_SystemInfoRequestString; }
string m_SystemInfoRequestString

Referenced by CWebService::GetTestID().

◆ GetSystemInformation()

void CConfiguration::GetSystemInformation ( )

Gets information about the running system and sets the appropriate configuration settings.

Definition at line 111 of file CConfiguration.cpp.

112 {
113  char ProductType;
114  GETSYSINFO GetSysInfo;
115  HMODULE hKernel32;
116  OSVERSIONINFOEXW os;
118  SYSTEM_INFO si;
119 
120  /* Get the build from the define */
121  ss << "&revision=";
122  ss << KERNEL_VERSION_COMMIT_HASH;
123 
124  ss << "&platform=";
125 
126  if(m_IsReactOS)
127  {
128  ss << "reactos";
129  }
130  else
131  {
132  /* No, then use the info from GetVersionExW */
133  os.dwOSVersionInfoSize = sizeof(os);
134 
136  FATAL("GetVersionExW failed\n");
137 
138  if(os.dwMajorVersion < 5)
139  EXCEPTION("Application requires at least Windows 2000!\n");
140 
141  if(os.wProductType == VER_NT_WORKSTATION)
142  ProductType = 'w';
143  else
144  ProductType = 's';
145 
146  /* Print all necessary identification information into the Platform string */
147  ss << os.dwMajorVersion << '.'
148  << os.dwMinorVersion << '.'
149  << os.dwBuildNumber << '.'
150  << os.wServicePackMajor << '.'
151  << os.wServicePackMinor << '.'
152  << ProductType << '.';
153  }
154 
155  /* We also need to know about the processor architecture.
156  To retrieve this information accurately, check whether "GetNativeSystemInfo" is exported and use it then, otherwise fall back to "GetSystemInfo". */
157  hKernel32 = GetModuleHandleW(L"KERNEL32.DLL");
158  GetSysInfo = (GETSYSINFO)GetProcAddress(hKernel32, "GetNativeSystemInfo");
159 
160  if(!GetSysInfo)
161  GetSysInfo = (GETSYSINFO)GetProcAddress(hKernel32, "GetSystemInfo");
162 
163  GetSysInfo(&si);
165 
167 }
#define VER_NT_WORKSTATION
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:265
#define FATAL(Message)
Definition: precomp.h:57
void(WINAPI * GETSYSINFO)(LPSYSTEM_INFO)
BOOL WINAPI GetVersionExW(IN LPOSVERSIONINFOW lpVersionInformation)
Definition: version.c:37
string m_SystemInfoRequestString
#define EXCEPTION(Message)
Definition: precomp.h:56
ULONG dwMajorVersion
Definition: rtltypes.h:243
ULONG dwBuildNumber
Definition: rtltypes.h:245
static const WCHAR L[]
Definition: oid.c:1250
WORD wProcessorArchitecture
Definition: winbase.h:1135
ULONG dwMinorVersion
Definition: rtltypes.h:244
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define GetProcAddress(x, y)
Definition: compat.h:418
#define ss
Definition: i386-dis.c:432

Referenced by wmain().

◆ GetTest()

const string& CConfiguration::GetTest ( ) const
inline

Definition at line 38 of file CConfiguration.h.

38 { return m_Test; }

Referenced by CWineTest::GetNextTestInfo().

◆ IsInteractive()

bool CConfiguration::IsInteractive ( ) const
inline

Definition at line 34 of file CConfiguration.h.

34 { return m_IsInteractive; }

Referenced by CWineTest::Run().

◆ IsReactOS()

bool CConfiguration::IsReactOS ( ) const
inline

Definition at line 35 of file CConfiguration.h.

35 { return m_IsReactOS; }

Referenced by CWineTest::Run().

◆ ParseParameters()

void CConfiguration::ParseParameters ( int  argc,
wchar_t argv[] 
)

Parses the passed parameters and sets the appropriate configuration settings.

Parameters
argcThe number of parameters (argc parameter of the wmain function)
argvPointer to a wchar_t array containing the parameters (argv parameter of the wmain function)

Definition at line 48 of file CConfiguration.cpp.

49 {
50  /* Parse the command line arguments */
51  for(int i = 1; i < argc; i++)
52  {
53  if(argv[i][0] == '-' || argv[i][0] == '/')
54  {
55  switch(argv[i][1])
56  {
57  case 'c':
58  ++i;
60  break;
61 
62  case 'n':
63  m_PrintToConsole = false;
64  break;
65 
66  case 'r':
67  m_CrashRecovery = true;
68  break;
69 
70  case 's':
71  m_Shutdown = true;
72  break;
73 
74  case 'w':
75  m_Submit = true;
76  break;
77 
78  default:
80  }
81  }
82  else
83  {
84  /* Which parameter is this? */
85  if(m_Module.empty())
86  {
87  /* Copy the parameter */
88  m_Module = argv[i];
89  }
90  else if(m_Test.empty())
91  {
92  /* Copy the parameter converted to ASCII */
94  }
95  else
96  {
98  }
99  }
100  }
101 
102  /* The /r and /w options shouldn't be used in conjunction */
105 }
static int argc
Definition: ServiceArgs.c:12
#define argv
Definition: mplay32.c:18
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
string UnicodeToAscii(PCWSTR UnicodeString)
Definition: tools.cpp:261

Referenced by wmain().

Member Data Documentation

◆ m_AuthenticationRequestString

string CConfiguration::m_AuthenticationRequestString
private

Definition at line 21 of file CConfiguration.h.

Referenced by GetAuthenticationRequestString(), and GetConfigurationFromFile().

◆ m_Comment

string CConfiguration::m_Comment
private

Definition at line 17 of file CConfiguration.h.

Referenced by GetComment(), GetConfigurationFromFile(), and ParseParameters().

◆ m_CrashRecovery

bool CConfiguration::m_CrashRecovery
private

Definition at line 11 of file CConfiguration.h.

Referenced by DoCrashRecovery(), and ParseParameters().

◆ m_IsInteractive

bool CConfiguration::m_IsInteractive
private

Definition at line 12 of file CConfiguration.h.

Referenced by CConfiguration(), and IsInteractive().

◆ m_IsReactOS

bool CConfiguration::m_IsReactOS
private

Definition at line 13 of file CConfiguration.h.

Referenced by CConfiguration(), GetSystemInformation(), and IsReactOS().

◆ m_Module

wstring CConfiguration::m_Module
private

Definition at line 18 of file CConfiguration.h.

Referenced by GetModule(), and ParseParameters().

◆ m_PrintToConsole

bool CConfiguration::m_PrintToConsole
private

Definition at line 14 of file CConfiguration.h.

Referenced by DoPrint(), and ParseParameters().

◆ m_Shutdown

bool CConfiguration::m_Shutdown
private

Definition at line 15 of file CConfiguration.h.

Referenced by DoShutdown(), and ParseParameters().

◆ m_Submit

bool CConfiguration::m_Submit
private

Definition at line 16 of file CConfiguration.h.

Referenced by DoSubmit(), GetConfigurationFromFile(), and ParseParameters().

◆ m_SystemInfoRequestString

string CConfiguration::m_SystemInfoRequestString
private

Definition at line 22 of file CConfiguration.h.

Referenced by GetSystemInfoRequestString(), and GetSystemInformation().

◆ m_Test

string CConfiguration::m_Test
private

Definition at line 19 of file CConfiguration.h.

Referenced by GetTest(), and ParseParameters().


The documentation for this class was generated from the following files: