ReactOS 0.4.16-dev-983-g23ad936
CConfiguration.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Automatic Testing Utility
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Class for managing all the configuration parameters
5 * COPYRIGHT: Copyright 2009-2011 Colin Finck (colin@reactos.org)
6 */
7
8#include "precomp.h"
9#include <versionhelpers.h>
10
11#define CONFIGURATION_FILENAMEA "rosautotest.ini"
12#define CONFIGURATION_FILENAMEW L"rosautotest.ini"
13
15
20 : m_CrashRecovery(false),
21 m_IsInteractive(false),
22 m_PrintToConsole(true),
23 m_RepeatCount(1),
24 m_Shutdown(false),
25 m_Submit(false),
26 m_ListModules(false)
27{
28 WCHAR WindowsDirectory[MAX_PATH];
30
31 /* Check if we are running under ReactOS from the SystemRoot directory */
32 if(!GetWindowsDirectoryW(WindowsDirectory, MAX_PATH))
33 FATAL("GetWindowsDirectoryW failed\n");
34
35 m_IsReactOS = !_wcsnicmp(&WindowsDirectory[3], L"reactos", 7);
37
38 if(GetEnvironmentVariableW(L"WINETEST_INTERACTIVE", Interactive, _countof(Interactive)))
40}
41
51void
53{
54 /* Parse the command line arguments */
55 for(int i = 1; i < argc; i++)
56 {
57 if(argv[i][0] == '-' || argv[i][0] == '/')
58 {
59 unsigned long tmp_RepeatCount;
60
61 switch(argv[i][1])
62 {
63 case 'c':
64 ++i;
65 if (i >= argc)
66 {
68 }
69
71 break;
72
73 case 'n':
74 m_PrintToConsole = false;
75 break;
76
77 case 'r':
78 m_CrashRecovery = true;
79 break;
80
81 case 's':
82 m_Shutdown = true;
83 break;
84
85 case 'w':
86 m_Submit = true;
87 break;
88
89 case 't':
90 ++i;
91 if (i >= argc)
92 {
94 }
95
96 tmp_RepeatCount = wcstoul(argv[i], NULL, 10);
97
98 if (tmp_RepeatCount == 0 || tmp_RepeatCount > 10000)
99 {
101 }
102
103 m_RepeatCount = tmp_RepeatCount;
104 break;
105
106 case 'l':
107 m_ListModules = true;
108 break;
109
110 default:
112 }
113 }
114 else
115 {
116 /* Which parameter is this? */
117 if(m_Module.empty())
118 {
119 /* Copy the parameter */
120 m_Module = argv[i];
121 }
122 else if(m_Test.empty())
123 {
124 /* Copy the parameter converted to ASCII */
126 }
127 else
128 {
130 }
131 }
132 }
133
134 /* The /r and /w options shouldn't be used in conjunction */
137}
138
142void
144{
145 char ProductType;
146 GETSYSINFO GetSysInfo;
150 SYSTEM_INFO si;
151
152 /* Get the build from the define */
153 ss << "&revision=";
154 ss << KERNEL_VERSION_COMMIT_HASH;
155
156 ss << "&platform=";
157
158 if(m_IsReactOS)
159 {
160 ss << "reactos";
161 }
162 else
163 {
164 /* No, then use the info from GetVersionExW */
165 os.dwOSVersionInfoSize = sizeof(os);
166
168 FATAL("GetVersionExW failed\n");
169
170 if(os.dwMajorVersion < 5)
171 EXCEPTION("Application requires at least Windows 2000!\n");
172
173 if(os.wProductType == VER_NT_WORKSTATION)
174 ProductType = 'w';
175 else
176 ProductType = 's';
177
178 /* Print all necessary identification information into the Platform string */
179 ss << os.dwMajorVersion << '.'
180 << os.dwMinorVersion << '.'
181 << os.dwBuildNumber << '.'
182 << os.wServicePackMajor << '.'
183 << os.wServicePackMinor << '.'
184 << ProductType << '.';
185 }
186
187 /* We also need to know about the processor architecture.
188 To retrieve this information accurately, check whether "GetNativeSystemInfo" is exported and use it then, otherwise fall back to "GetSystemInfo". */
189 hKernel32 = GetModuleHandleW(L"KERNEL32.DLL");
190 GetSysInfo = (GETSYSINFO)GetProcAddress(hKernel32, "GetNativeSystemInfo");
191
192 if(!GetSysInfo)
193 GetSysInfo = (GETSYSINFO)GetProcAddress(hKernel32, "GetSystemInfo");
194
195 GetSysInfo(&si);
197
199}
200
206void
208{
210 string Value;
211 WCHAR ConfigFile[MAX_PATH];
212
213 /* Most values are only needed if we're going to submit anything */
214 if(m_Submit)
215 {
216 /* Build the path to the configuration file from the application's path */
217 GetModuleFileNameW(NULL, ConfigFile, MAX_PATH);
218 Length = wcsrchr(ConfigFile, '\\') - ConfigFile + 1;
220
221 /* Check if it exists */
223 EXCEPTION("Missing \"" CONFIGURATION_FILENAMEA "\" configuration file!\n");
224
225 /* Get the user name */
226 m_AuthenticationRequestString = "&sourceid=";
227 Value = GetINIValue(L"Login", L"SourceID", ConfigFile);
228
229 if(Value.empty())
230 EXCEPTION("SourceID is missing in the configuration file\n");
231
233
234 /* Get the password */
235 m_AuthenticationRequestString += "&password=";
236 Value = GetINIValue(L"Login", L"Password", ConfigFile);
237
238 if(Value.empty())
239 EXCEPTION("Password is missing in the configuration file\n");
240
242
243 /* If we don't have any Comment string yet, try to find one in the INI file */
244 if(m_Comment.empty())
245 m_Comment = GetINIValue(L"Submission", L"Comment", ConfigFile);
246 }
247}
void(WINAPI * GETSYSINFO)(LPSYSTEM_INFO)
#define CONFIGURATION_FILENAMEW
#define CONFIGURATION_FILENAMEA
static int argc
Definition: ServiceArgs.c:12
unsigned long m_RepeatCount
void GetSystemInformation()
void GetConfigurationFromFile()
bool IsReactOS() const
string m_SystemInfoRequestString
void ParseParameters(int argc, wchar_t *argv[])
string m_AuthenticationRequestString
wcscpy
#define NULL
Definition: types.h:112
#define wcsrchr
Definition: compat.h:16
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:755
#define GetProcAddress(x, y)
Definition: compat.h:753
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
BOOL WINAPI GetVersionExW(IN LPOSVERSIONINFOW lpVersionInformation)
Definition: version.c:37
unsigned long DWORD
Definition: ntddk_ex.h:95
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
#define ss
Definition: i386-dis.c:441
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
HANDLE hKernel32
Definition: locale.c:13
string GetINIValue(PCWCH AppName, PCWCH KeyName, PCWCH FileName)
Definition: tools.cpp:187
#define EXCEPTION(Message)
Definition: precomp.h:56
string UnicodeToAscii(PCWSTR UnicodeString)
Definition: tools.cpp:261
string EscapeString(const char *Input)
Definition: tools.cpp:24
#define FATAL(Message)
Definition: precomp.h:57
#define argv
Definition: mplay32.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
@ Interactive
Definition: ntsecapi.h:289
#define L(x)
Definition: ntvdm.h:50
_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)
#define _countof(array)
Definition: sndvol32.h:70
#define true
Definition: stdbool.h:36
#define false
Definition: stdbool.h:37
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:269
ULONG dwMinorVersion
Definition: rtltypes.h:248
ULONG dwMajorVersion
Definition: rtltypes.h:247
ULONG dwBuildNumber
Definition: rtltypes.h:249
WORD wProcessorArchitecture
Definition: winbase.h:1200
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
struct _SYSTEM_INFO * LPSYSTEM_INFO
#define WINAPI
Definition: msvc.h:6
#define VER_NT_WORKSTATION
__wchar_t WCHAR
Definition: xmlstorage.h:180