ReactOS
0.4.16-dev-297-gc569aee
Toggle main menu visibility
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
Functions
_
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
Variables
_
c
d
e
f
g
h
i
l
n
o
p
s
t
u
x
Typedefs
_
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
x
Enumerations
_
c
d
f
i
l
m
o
p
s
t
w
x
Enumerator
a
b
c
d
e
f
g
h
i
m
n
o
p
r
s
t
u
v
w
x
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
z
Enumerator
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Related Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
v
x
Files
File List
File Members
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Examples
diskpart.c
Go to the documentation of this file.
1
/*
2
* PROJECT: ReactOS DiskPart
3
* LICENSE: GPL - See COPYING in the top level directory
4
* FILE: base/system/diskpart/diskpart.c
5
* PURPOSE: Manages all the partitions of the OS in an interactive way.
6
* PROGRAMMERS: Lee Schroeder
7
*/
8
9
/* INCLUDES ******************************************************************/
10
11
#include "
diskpart.h
"
12
13
/* FUNCTIONS ******************************************************************/
14
15
VOID
16
ShowHeader
(
VOID
)
17
{
18
WCHAR
szComputerName[
MAX_STRING_SIZE
];
19
DWORD
comp_size =
MAX_STRING_SIZE
;
20
21
/* Get the name of the computer for us and change the value of comp_name */
22
GetComputerNameW
(szComputerName, &comp_size);
23
24
/* TODO: Remove this section of code when program becomes stable enough for production use. */
25
ConPuts
(
StdOut
,
L
"\n*WARNING*: This program is incomplete and may not work properly.\n"
);
26
27
/* Print the header information */
28
ConPuts
(
StdOut
,
L
"\n"
);
29
ConResPuts
(
StdOut
,
IDS_APP_HEADER
);
30
ConPuts
(
StdOut
,
L
"\n"
);
31
ConResPuts
(
StdOut
,
IDS_APP_LICENSE
);
32
ConResPrintf
(
StdOut
,
IDS_APP_CURR_COMPUTER
, szComputerName);
33
}
34
35
/*
36
* RunScript(const char *filename):
37
* opens the file, reads the contents, convert the text into readable
38
* code for the computer, and then execute commands in order.
39
*/
40
BOOL
41
RunScript
(
LPCWSTR
filename
)
42
{
43
FILE
*
script
;
44
WCHAR
tmp_string[
MAX_STRING_SIZE
];
45
46
/* Open the file for processing */
47
script
=
_wfopen
(
filename
,
L
"r"
);
48
if
(
script
==
NULL
)
49
{
50
/* if there was problems opening the file */
51
ConResPrintf
(
StdErr
,
IDS_ERROR_MSG_NO_SCRIPT
,
filename
);
52
return
FALSE
;
/* if there is no script, exit the program */
53
}
54
55
/* Read and process the script */
56
while
(
fgetws
(tmp_string,
MAX_STRING_SIZE
,
script
) !=
NULL
)
57
{
58
if
(
InterpretScript
(tmp_string) ==
FALSE
)
59
{
60
fclose
(
script
);
61
return
FALSE
;
62
}
63
}
64
65
/* Close the file */
66
fclose
(
script
);
67
68
return
TRUE
;
69
}
70
71
/*
72
* wmain():
73
* Main entry point of the application.
74
*/
75
int
wmain
(
int
argc
,
const
LPWSTR
argv
[])
76
{
77
LPCWSTR
script
=
NULL
;
78
LPCWSTR
tmpBuffer =
NULL
;
79
WCHAR
appTitle[50];
80
int
index
,
timeout
;
81
int
result
=
EXIT_SUCCESS
;
82
83
/* Initialize the Console Standard Streams */
84
ConInitStdStreams
();
85
86
/* Sets the title of the program so the user will have an easier time
87
determining the current program, especially if diskpart is running a
88
script */
89
K32LoadStringW
(
GetModuleHandle
(
NULL
),
IDS_APP_HEADER
, appTitle,
ARRAYSIZE
(appTitle));
90
SetConsoleTitleW
(appTitle);
91
92
/* Sets the timeout value to 0 just in case the user doesn't
93
specify a value */
94
timeout
= 0;
95
96
CreatePartitionList
();
97
CreateVolumeList
();
98
99
/* If there are no command arguments, then go straight to the interpreter */
100
if
(
argc
< 2)
101
{
102
ShowHeader
();
103
InterpretMain
();
104
}
105
/* If there are command arguments, then process them */
106
else
107
{
108
for
(
index
= 1;
index
<
argc
;
index
++)
109
{
110
/* checks for flags */
111
if
((
argv
[
index
][0] ==
'/'
)||
112
(
argv
[
index
][0] ==
'-'
))
113
{
114
tmpBuffer =
argv
[
index
] + 1;
115
}
116
else
117
{
118
/* If there is no flag, then return an error */
119
ConResPrintf
(
StdErr
,
IDS_ERROR_MSG_BAD_ARG
,
argv
[
index
]);
120
result
=
EXIT_FAILURE
;
121
goto
done;
122
}
123
124
/* Checks for the /? flag first since the program
125
exits as soon as the usage list is shown. */
126
if
(
_wcsicmp
(tmpBuffer,
L
"?"
) == 0)
127
{
128
ConResPuts
(
StdOut
,
IDS_APP_USAGE
);
129
result
=
EXIT_SUCCESS
;
130
goto
done;
131
}
132
/* Checks for the script flag */
133
else
if
(
_wcsicmp
(tmpBuffer,
L
"s"
) == 0)
134
{
135
if
((
index
+ 1) <
argc
)
136
{
137
index
++;
138
script
=
argv
[
index
];
139
}
140
}
141
/* Checks for the timeout flag */
142
else
if
(
_wcsicmp
(tmpBuffer,
L
"t"
) == 0)
143
{
144
if
((
index
+ 1) <
argc
)
145
{
146
index
++;
147
timeout
=
_wtoi
(
argv
[
index
]);
148
149
/* If the number is a negative number, then
150
change it so that the time is executed properly. */
151
if
(
timeout
< 0)
152
timeout
= 0;
153
}
154
}
155
else
156
{
157
/* Assume that the flag doesn't exist. */
158
ConResPrintf
(
StdErr
,
IDS_ERROR_MSG_BAD_ARG
, tmpBuffer);
159
result
=
EXIT_FAILURE
;
160
goto
done;
161
}
162
}
163
164
/* Shows the program information */
165
ShowHeader
();
166
167
/* Now we process the filename if it exists */
168
if
(
script
!=
NULL
)
169
{
170
/* if the timeout is greater than 0, then assume
171
that the user specified a specific time. */
172
if
(
timeout
> 0)
173
Sleep
(
timeout
* 1000);
174
175
if
(
RunScript
(
script
) ==
FALSE
)
176
{
177
result
=
EXIT_FAILURE
;
178
goto
done;
179
}
180
}
181
else
182
{
183
/* Exit failure since the user wanted to run a script */
184
ConResPrintf
(
StdErr
,
IDS_ERROR_MSG_NO_SCRIPT
,
script
);
185
result
=
EXIT_FAILURE
;
186
goto
done;
187
}
188
}
189
190
/* Let the user know the program is exiting */
191
ConResPuts
(
StdOut
,
IDS_APP_LEAVING
);
192
193
done:
194
DestroyVolumeList
();
195
DestroyPartitionList
();
196
197
return
result
;
198
}
argc
static int argc
Definition:
ServiceArgs.c:12
InterpretScript
BOOL InterpretScript(_In_ LPWSTR pszInputLine)
Definition:
interpreter.c:150
ConPuts
void ConPuts(FILE *fp, LPCWSTR psz)
Definition:
fc.c:16
ConInitStdStreams
#define ConInitStdStreams()
Definition:
fc.c:13
StdOut
#define StdOut
Definition:
fc.c:14
ConResPrintf
void ConResPrintf(FILE *fp, UINT nID,...)
Definition:
fc.c:33
StdErr
#define StdErr
Definition:
fc.c:15
ConResPuts
void ConResPuts(FILE *fp, UINT nID)
Definition:
fc.c:27
index
#define index(s, c)
Definition:
various.h:29
MAX_STRING_SIZE
#define MAX_STRING_SIZE
Definition:
precomp.h:34
IDS_APP_USAGE
#define IDS_APP_USAGE
Definition:
resource.h:12
IDS_ERROR_MSG_NO_SCRIPT
#define IDS_ERROR_MSG_NO_SCRIPT
Definition:
resource.h:185
IDS_APP_CURR_COMPUTER
#define IDS_APP_CURR_COMPUTER
Definition:
resource.h:17
IDS_APP_LICENSE
#define IDS_APP_LICENSE
Definition:
resource.h:16
IDS_APP_HEADER
#define IDS_APP_HEADER
Definition:
resource.h:14
IDS_APP_LEAVING
#define IDS_APP_LEAVING
Definition:
resource.h:18
IDS_ERROR_MSG_BAD_ARG
#define IDS_ERROR_MSG_BAD_ARG
Definition:
resource.h:186
GetComputerNameW
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition:
compname.c:446
RunScript
BOOL RunScript(LPCWSTR filename)
Definition:
diskpart.c:41
ShowHeader
VOID ShowHeader(VOID)
Definition:
diskpart.c:16
diskpart.h
DestroyVolumeList
VOID DestroyVolumeList(VOID)
Definition:
partlist.c:1450
CreateVolumeList
NTSTATUS CreateVolumeList(VOID)
Definition:
partlist.c:1412
InterpretMain
VOID InterpretMain(VOID)
Definition:
interpreter.c:231
NULL
#define NULL
Definition:
types.h:112
TRUE
#define TRUE
Definition:
types.h:120
FALSE
#define FALSE
Definition:
types.h:117
ARRAYSIZE
#define ARRAYSIZE(array)
Definition:
filtermapper.c:47
SetConsoleTitleW
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleTitleW(LPCWSTR lpConsoleTitle)
Definition:
console.c:2290
BOOL
unsigned int BOOL
Definition:
ntddk_ex.h:94
DWORD
unsigned long DWORD
Definition:
ntddk_ex.h:95
index
GLuint index
Definition:
glext.h:6031
result
GLuint64EXT * result
Definition:
glext.h:11304
_wfopen
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
fclose
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_wtoi
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
void
Definition:
nsiface.idl:2307
filename
const char * filename
Definition:
ioapi.h:137
EXIT_FAILURE
#define EXIT_FAILURE
Definition:
jerror.c:33
argv
#define argv
Definition:
mplay32.c:18
script
script
Definition:
msipriv.h:383
L
#define L(x)
Definition:
ntvdm.h:50
wmain
int wmain()
Definition:
rdesktop-core-tester.cpp:552
EXIT_SUCCESS
#define EXIT_SUCCESS
Definition:
rdjpgcom.c:55
_wcsicmp
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
K32LoadStringW
INT WINAPI K32LoadStringW(IN HINSTANCE hInstance OPTIONAL, IN UINT uID, OUT LPWSTR lpBuffer, IN INT nBufferMax)
Definition:
utils.c:173
DestroyPartitionList
VOID DestroyPartitionList(IN PPARTLIST List)
Definition:
partlist.c:2072
CreatePartitionList
PPARTLIST CreatePartitionList(VOID)
Definition:
partlist.c:1987
_iobuf
Definition:
mbstring.h:19
timeout
Definition:
dhcpd.h:245
Sleep
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition:
synch.c:790
GetModuleHandle
#define GetModuleHandle
Definition:
winbase.h:3852
fgetws
wchar_t * fgetws(wchar_t *buf, int bufsize, FILE *file)
Definition:
wmain.c:22
WCHAR
__wchar_t WCHAR
Definition:
xmlstorage.h:180
LPWSTR
WCHAR * LPWSTR
Definition:
xmlstorage.h:184
LPCWSTR
const WCHAR * LPCWSTR
Definition:
xmlstorage.h:185
base
system
diskpart
diskpart.c
Generated on Tue Nov 26 2024 06:02:35 for ReactOS by
1.9.6