ReactOS  0.4.15-dev-985-gd905dd5
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

static VOID SelectDisk (INT argc, LPWSTR *argv)
 
static VOID SelectPartition (INT argc, LPWSTR *argv)
 
BOOL select_main (INT argc, LPWSTR *argv)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file select.c.

Function Documentation

◆ select_main()

BOOL select_main ( INT  argc,
LPWSTR argv 
)

Definition at line 161 of file select.c.

164 {
165  /* gets the first word from the string */
166  if (argc == 1)
167  {
169  return TRUE;
170  }
171 
172  /* determines which to list (disk, partition, etc.) */
173  if (!wcsicmp(argv[1], L"disk"))
174  SelectDisk(argc, argv);
175  else if (!wcsicmp(argv[1], L"partition"))
177  else
179 
180  return TRUE;
181 }
static VOID SelectPartition(INT argc, LPWSTR *argv)
Definition: select.c:76
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
#define argv
Definition: mplay32.c:18
static VOID SelectDisk(INT argc, LPWSTR *argv)
Definition: select.c:18
#define wcsicmp
Definition: compat.h:15
#define IDS_HELP_CMD_SELECT
Definition: resource.h:142
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
static const WCHAR L[]
Definition: oid.c:1250
#define StdOut
Definition: stream.h:82

◆ SelectDisk()

static VOID SelectDisk ( INT  argc,
LPWSTR argv 
)
static

Definition at line 18 of file select.c.

21 {
23  PDISKENTRY DiskEntry;
24  LONG lValue;
25  LPWSTR endptr = NULL;
26 
27  DPRINT("Select Disk()\n");
28 
29  if (argc > 3)
30  {
32  return;
33  }
34 
35  if (argc == 2)
36  {
37  if (CurrentDisk == NULL)
39  else
41  return;
42  }
43 
44  lValue = wcstol(argv[2], &endptr, 10);
45  if (((lValue == 0) && (endptr == argv[2])) ||
46  (lValue < 0))
47  {
49  return;
50  }
51 
52  CurrentDisk = NULL;
53 
55  while (Entry != &DiskListHead)
56  {
57  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
58 
59  if (DiskEntry->DiskNumber == (ULONG)lValue)
60  {
61  CurrentDisk = DiskEntry;
64  return;
65  }
66 
67  Entry = Entry->Flink;
68  }
69 
71 }
static int argc
Definition: ServiceArgs.c:12
struct _Entry Entry
Definition: kefuncs.h:627
#define IDS_SELECT_DISK_INVALID
Definition: resource.h:49
ULONG DiskNumber
Definition: partlist.h:104
static PPARTENTRY CurrentPartition
Definition: usetup.c:76
PDISKENTRY CurrentDisk
Definition: partlist.c:73
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define argv
Definition: mplay32.c:18
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:147
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
LIST_ENTRY DiskListHead
Definition: partlist.c:70
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:781
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define IDS_SELECT_NO_DISK
Definition: resource.h:47
#define StdErr
Definition: stream.h:83
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
Definition: typedefs.h:119
#define IDS_SELECT_DISK
Definition: resource.h:48
#define StdOut
Definition: stream.h:82
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
base of all file and directory entries
Definition: entries.h:82

Referenced by select_main().

◆ SelectPartition()

static VOID SelectPartition ( INT  argc,
LPWSTR argv 
)
static

Definition at line 76 of file select.c.

79 {
81  PPARTENTRY PartEntry;
82  LONG lValue;
83  LPWSTR endptr = NULL;
84  ULONG PartNumber = 1;
85 
86  DPRINT("Select Partition()\n");
87 
88  if (argc > 3)
89  {
91  return;
92  }
93 
94  if (CurrentDisk == NULL)
95  {
97  return;
98  }
99 
100  if (argc == 2)
101  {
102  if (CurrentPartition == NULL)
104  else
106  return;
107  }
108 
109  lValue = wcstol(argv[2], &endptr, 10);
110  if (((lValue == 0) && (endptr == argv[2])) ||
111  (lValue < 0))
112  {
114  return;
115  }
116 
119  {
120  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
121 
122  if (PartEntry->PartitionType != 0)
123  {
124  if (PartNumber == (ULONG)lValue)
125  {
126  CurrentPartition = PartEntry;
128  return;
129  }
130 
131  PartNumber++;
132  }
133 
134  Entry = Entry->Flink;
135  }
136 
139  {
140  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
141 
142  if (PartEntry->PartitionType != 0)
143  {
144  if (PartNumber == (ULONG)lValue)
145  {
146  CurrentPartition = PartEntry;
148  return;
149  }
150 
151  PartNumber++;
152  }
153  Entry = Entry->Flink;
154  }
155 
157 }
#define IDS_SELECT_PARTITION_INVALID
Definition: resource.h:53
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:124
#define IDS_SELECT_NO_PARTITION
Definition: resource.h:50
static int argc
Definition: ServiceArgs.c:12
struct _Entry Entry
Definition: kefuncs.h:627
static PPARTENTRY CurrentPartition
Definition: usetup.c:76
PDISKENTRY CurrentDisk
Definition: partlist.c:73
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define argv
Definition: mplay32.c:18
#define IDS_SELECT_PARTITION
Definition: resource.h:51
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:147
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:781
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
UCHAR PartitionType
Definition: partlist.h:46
#define StdErr
Definition: stream.h:83
#define IDS_SELECT_PARTITION_NO_DISK
Definition: resource.h:52
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
Definition: typedefs.h:119
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:125
#define StdOut
Definition: stream.h:82
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
base of all file and directory entries
Definition: entries.h:82

Referenced by select_main().