ReactOS 0.4.16-dev-1990-gfa5cf28
select.c File Reference
#include "diskpart.h"
#include <debug.h>
Include dependency graph for select.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOL SelectDisk (INT argc, PWSTR *argv)
 
BOOL SelectPartition (INT argc, PWSTR *argv)
 
BOOL SelectVolume (INT argc, PWSTR *argv)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file select.c.

Function Documentation

◆ SelectDisk()

BOOL SelectDisk ( INT  argc,
PWSTR argv 
)

Definition at line 17 of file select.c.

20{
22 PDISKENTRY DiskEntry;
23 ULONG ulValue;
24
25 DPRINT("Select Disk()\n");
26
27 if (argc > 3)
28 {
30 return TRUE;
31 }
32
33 if (argc == 2)
34 {
35 if (CurrentDisk == NULL)
37 else
39 return TRUE;
40 }
41
42 if (!_wcsicmp(argv[2], L"system"))
43 {
45
47 DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
48
49 CurrentDisk = DiskEntry;
52 return TRUE;
53 }
54 else if (!_wcsicmp(argv[2], L"next"))
55 {
56 if (CurrentDisk == NULL)
57 {
60 return TRUE;
61 }
62
64 {
68 return TRUE;
69 }
70
72
73 DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
74
75 CurrentDisk = DiskEntry;
78 return TRUE;
79 }
80 else if (IsDecString(argv[2]))
81 {
82 ulValue = wcstoul(argv[2], NULL, 10);
83 if ((ulValue == 0) && (errno == ERANGE))
84 {
86 return TRUE;
87 }
88
90
92 while (Entry != &DiskListHead)
93 {
94 DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
95
96 if (DiskEntry->DiskNumber == ulValue)
97 {
98 CurrentDisk = DiskEntry;
101 return TRUE;
102 }
103
104 Entry = Entry->Flink;
105 }
106 }
107 else
108 {
110 return TRUE;
111 }
112
114 return TRUE;
115}
static int argc
Definition: ServiceArgs.c:12
#define ERANGE
Definition: acclib.h:92
#define StdOut
Definition: fc.c:14
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
#define StdErr
Definition: fc.c:15
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
#define IDS_SELECT_DISK_INVALID
Definition: resource.h:97
#define IDS_SELECT_DISK_ENUM_NO_START
Definition: resource.h:98
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:203
#define IDS_SELECT_DISK
Definition: resource.h:96
#define IDS_SELECT_NO_DISK
Definition: resource.h:95
#define IDS_SELECT_DISK_ENUM_FINISHED
Definition: resource.h:99
PDISKENTRY CurrentDisk
Definition: partlist.c:77
LIST_ENTRY DiskListHead
Definition: partlist.c:73
BOOL IsDecString(_In_ PWSTR pszDecString)
Definition: misc.c:14
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define L(x)
Definition: resources.c:13
#define argv
Definition: mplay32.c:18
#define errno
Definition: errno.h:18
_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 _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
Definition: _wcsicmp_nt.c:13
#define DPRINT
Definition: sndvol32.h:73
base of all file and directory entries
Definition: entries.h:83
ULONG DiskNumber
Definition: partlist.h:129
LIST_ENTRY ListEntry
Definition: partlist.h:101
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
static PPARTENTRY CurrentPartition
Definition: usetup.c:78

◆ SelectPartition()

BOOL SelectPartition ( INT  argc,
PWSTR argv 
)

Definition at line 119 of file select.c.

122{
124 PPARTENTRY PartEntry;
125 ULONG ulValue;
126 ULONG PartNumber = 1;
127
128 DPRINT("Select Partition()\n");
129
130 if (argc > 3)
131 {
133 return TRUE;
134 }
135
136 if (CurrentDisk == NULL)
137 {
139 return TRUE;
140 }
141
142 if (argc == 2)
143 {
144 if (CurrentPartition == NULL)
146 else
148 return TRUE;
149 }
150
151 if (!IsDecString(argv[2]))
152 {
154 return TRUE;
155 }
156
157 ulValue = wcstoul(argv[2], NULL, 10);
158 if ((ulValue == 0) && (errno == ERANGE))
159 {
161 return TRUE;
162 }
163
165 {
168 {
169 PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
170
171 if (PartEntry->Mbr.PartitionType != PARTITION_ENTRY_UNUSED)
172 {
173 if (PartNumber == ulValue)
174 {
175 CurrentPartition = PartEntry;
177 return TRUE;
178 }
179
180 PartNumber++;
181 }
182
183 Entry = Entry->Flink;
184 }
185
188 {
189 PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
190
191 if (PartEntry->Mbr.PartitionType != PARTITION_ENTRY_UNUSED)
192 {
193 if (PartNumber == ulValue)
194 {
195 CurrentPartition = PartEntry;
197 return TRUE;
198 }
199
200 PartNumber++;
201 }
202 Entry = Entry->Flink;
203 }
204 }
206 {
209 {
210 PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
211
212 if (!IsEqualGUID(&PartEntry->Gpt.PartitionType, &PARTITION_ENTRY_UNUSED_GUID))
213 {
214 if (PartNumber == ulValue)
215 {
216 CurrentPartition = PartEntry;
218 return TRUE;
219 }
220
221 PartNumber++;
222 }
223
224 Entry = Entry->Flink;
225 }
226 }
227
229 return TRUE;
230}
#define IDS_SELECT_NO_PARTITION
Definition: resource.h:100
#define IDS_SELECT_PARTITION_NO_DISK
Definition: resource.h:102
#define IDS_SELECT_PARTITION_INVALID
Definition: resource.h:103
#define IDS_SELECT_PARTITION
Definition: resource.h:101
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:71
@ PARTITION_STYLE_GPT
Definition: imports.h:202
@ PARTITION_STYLE_MBR
Definition: imports.h:201
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:150
DWORD PartitionStyle
Definition: diskpart.h:202
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:149
MBR_PARTITION_DATA Mbr
Definition: diskpart.h:128
GPT_PARTITION_DATA Gpt
Definition: diskpart.h:129

◆ SelectVolume()

BOOL SelectVolume ( INT  argc,
PWSTR argv 
)

Definition at line 234 of file select.c.

237{
239 PVOLENTRY VolumeEntry;
240 ULONG ulValue;
241
242 DPRINT("SelectVolume()\n");
243
244 if (argc > 3)
245 {
247 return TRUE;
248 }
249
250 if (argc == 2)
251 {
252 if (CurrentDisk == NULL)
254 else
256 return TRUE;
257 }
258
259 if (!IsDecString(argv[2]))
260 {
262 return TRUE;
263 }
264
265 ulValue = wcstoul(argv[2], NULL, 10);
266 if ((ulValue == 0) && (errno == ERANGE))
267 {
269 return TRUE;
270 }
271
273
275 while (Entry != &VolumeListHead)
276 {
277 VolumeEntry = CONTAINING_RECORD(Entry, VOLENTRY, ListEntry);
278
279 if (VolumeEntry->VolumeNumber == ulValue)
280 {
281 CurrentVolume = VolumeEntry;
283 return TRUE;
284 }
285
286 Entry = Entry->Flink;
287 }
288
290 return TRUE;
291}
#define IDS_SELECT_NO_VOLUME
Definition: resource.h:104
#define IDS_SELECT_VOLUME
Definition: resource.h:105
#define IDS_SELECT_VOLUME_INVALID
Definition: resource.h:106
LIST_ENTRY VolumeListHead
Definition: partlist.c:75
PVOLENTRY CurrentVolume
Definition: partlist.c:79
ULONG VolumeNumber
Definition: diskpart.h:219