ReactOS  0.4.15-dev-1171-gab82533
fslist.c
Go to the documentation of this file.
1 /*
2  * ReactOS kernel
3  * Copyright (C) 2003 ReactOS Team
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 /*
20  * COPYRIGHT: See COPYING in the top level directory
21  * PROJECT: ReactOS text-mode setup
22  * FILE: base/setup/usetup/fslist.c
23  * PURPOSE: Filesystem list functions
24  * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
25  */
26 
27 #include "usetup.h"
28 
29 #define NDEBUG
30 #include <debug.h>
31 
32 /* Enable this define to hide FAT32 choice in case FAT is already present */
33 #define HIDE_FAT32_CHOICE
34 
35 /* FUNCTIONS ****************************************************************/
36 
37 static VOID
41 {
42  PFILE_SYSTEM_ITEM Item;
43 
44  Item = (PFILE_SYSTEM_ITEM)RtlAllocateHeap(ProcessHeap, 0, sizeof(*Item));
45  if (!Item)
46  return;
47 
48  Item->FileSystem = FileSystem;
49  Item->QuickFormat = TRUE;
50  InsertTailList(&List->ListHead, &Item->ListEntry);
51 
52  if (!FileSystem)
53  return;
54 
55  Item = (PFILE_SYSTEM_ITEM)RtlAllocateHeap(ProcessHeap, 0, sizeof(*Item));
56  if (!Item)
57  return;
58 
59  Item->FileSystem = FileSystem;
60  Item->QuickFormat = FALSE;
61  InsertTailList(&List->ListHead, &Item->ListEntry);
62 }
63 
64 static VOID
67  IN BOOLEAN ForceFormat)
68 {
69  PCWSTR FileSystemName;
70  ULONG Index;
71 
72 #ifdef HIDE_FAT32_CHOICE
73  BOOLEAN FatPresent = FALSE;
74 
75  /* Check whether the FAT filesystem is present */
76  Index = 0;
77  while (GetRegisteredFileSystems(Index++, &FileSystemName))
78  {
79  if (wcsicmp(FileSystemName, L"FAT") == 0)
80  {
81  FatPresent = TRUE;
82  break;
83  }
84  }
85 
86 #endif
87 
88  Index = 0;
89  while (GetRegisteredFileSystems(Index++, &FileSystemName))
90  {
91 #ifdef HIDE_FAT32_CHOICE
92  /* USETUP only: If the FAT filesystem is present, show it, but
93  * don't display FAT32. The FAT formatter will automatically
94  * determine whether to use FAT12/16 or FAT32. */
95  if (FatPresent && wcsicmp(FileSystemName, L"FAT32") == 0)
96  continue;
97 #endif
98  AddProvider(List, FileSystemName);
99  }
100 
101  if (!ForceFormat)
102  {
103  /* Add the 'Keep existing filesystem' dummy provider */
105  }
106 }
107 
110  IN SHORT Left,
111  IN SHORT Top,
112  IN BOOLEAN ForceFormat,
113  IN PCWSTR SelectFileSystem)
114 {
116  PFILE_SYSTEM_ITEM Item;
117  PLIST_ENTRY ListEntry;
118 
120  if (List == NULL)
121  return NULL;
122 
123  List->Left = Left;
124  List->Top = Top;
125  List->Selected = NULL;
126  InitializeListHead(&List->ListHead);
127 
128  InitializeFileSystemList(List, ForceFormat);
129 
130  /* Search for SelectFileSystem in list */
131  ListEntry = List->ListHead.Flink;
132  while (ListEntry != &List->ListHead)
133  {
134  Item = CONTAINING_RECORD(ListEntry, FILE_SYSTEM_ITEM, ListEntry);
135  if (Item->FileSystem && wcsicmp(SelectFileSystem, Item->FileSystem) == 0)
136  {
137  List->Selected = Item;
138  break;
139  }
140  ListEntry = ListEntry->Flink;
141  }
142  if (!List->Selected)
143  List->Selected = CONTAINING_RECORD(List->ListHead.Flink, FILE_SYSTEM_ITEM, ListEntry);
144 
145  return List;
146 }
147 
148 VOID
151 {
152  PLIST_ENTRY ListEntry;
153  PFILE_SYSTEM_ITEM Item;
154 
155  ListEntry = List->ListHead.Flink;
156  while (!IsListEmpty(&List->ListHead))
157  {
158  ListEntry = RemoveHeadList(&List->ListHead);
159  Item = CONTAINING_RECORD(ListEntry, FILE_SYSTEM_ITEM, ListEntry);
160  RtlFreeHeap(ProcessHeap, 0, Item);
161  }
162 
164 }
165 
166 VOID
169 {
170  PLIST_ENTRY ListEntry;
171  PFILE_SYSTEM_ITEM Item;
172  COORD coPos;
173  DWORD Written;
174  ULONG Index = 0;
175  CHAR Buffer[128];
176 
177  ListEntry = List->ListHead.Flink;
178  while (ListEntry != &List->ListHead)
179  {
180  Item = CONTAINING_RECORD(ListEntry, FILE_SYSTEM_ITEM, ListEntry);
181 
182  coPos.X = List->Left;
183  coPos.Y = List->Top + (SHORT)Index;
186  sizeof(Buffer),
187  coPos,
188  &Written);
190  ' ',
191  sizeof(Buffer),
192  coPos,
193  &Written);
194 
195  if (Item->FileSystem)
196  {
197  snprintf(Buffer, sizeof(Buffer),
200  Item->FileSystem);
201  }
202  else
203  {
205  }
206 
207  if (ListEntry == &List->Selected->ListEntry)
208  {
210  List->Top + (SHORT)Index,
211  Buffer);
212  }
213  else
214  {
215  CONSOLE_SetTextXY(List->Left,
216  List->Top + (SHORT)Index,
217  Buffer);
218  }
219  Index++;
220  ListEntry = ListEntry->Flink;
221  }
222 }
223 
224 VOID
227 {
228  if (List->Selected->ListEntry.Flink != &List->ListHead)
229  {
230  List->Selected = CONTAINING_RECORD(List->Selected->ListEntry.Flink, FILE_SYSTEM_ITEM, ListEntry);
232  }
233 }
234 
235 VOID
238 {
239  if (List->Selected->ListEntry.Blink != &List->ListHead)
240  {
241  List->Selected = CONTAINING_RECORD(List->Selected->ListEntry.Blink, FILE_SYSTEM_ITEM, ListEntry);
243  }
244 }
245 
246 /* EOF */
#define STRING_KEEPFORMAT
Definition: mui.h:151
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define IN
Definition: typedefs.h:39
VOID CONSOLE_SetTextXY(IN SHORT x, IN SHORT y, IN LPCSTR Text)
Definition: consup.c:311
BOOL WINAPI FillConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
Definition: console.c:522
PWCHAR FileSystem
Definition: format.c:72
static VOID AddProvider(IN OUT PFILE_SYSTEM_LIST List, IN PCWSTR FileSystem)
Definition: fslist.c:38
#define TRUE
Definition: types.h:120
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
char CHAR
Definition: xmlstorage.h:175
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
PCWSTR FileSystem
Definition: fslist.h:34
#define snprintf
Definition: wintirpc.h:48
#define InsertTailList(ListHead, Entry)
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define FOREGROUND_WHITE
Definition: consup.h:29
BOOL WINAPI FillConsoleOutputCharacterA(IN HANDLE hConsoleOutput, IN CHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:557
LIST_ENTRY ListEntry
Definition: fslist.h:33
VOID ScrollDownFileSystemList(IN PFILE_SYSTEM_LIST List)
Definition: fslist.c:225
#define FALSE
Definition: types.h:117
short SHORT
Definition: pedump.c:59
HANDLE StdOutput
Definition: consup.c:37
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
Definition: bufpool.h:45
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
#define STRING_FORMATDISK1
Definition: mui.h:149
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
ULONG X
Definition: bl.h:1340
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
static VOID InitializeFileSystemList(IN OUT PFILE_SYSTEM_LIST List, IN BOOLEAN ForceFormat)
Definition: fslist.c:65
LIST_ENTRY List
Definition: psmgr.c:57
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
#define wcsicmp
Definition: compat.h:15
VOID CONSOLE_SetInvertedTextXY(IN SHORT x, IN SHORT y, IN LPCSTR Text)
Definition: consup.c:535
BOOLEAN GetRegisteredFileSystems(IN ULONG Index, OUT PCWSTR *FileSystemName)
Definition: fsutil.c:155
static const WCHAR L[]
Definition: oid.c:1250
VOID ScrollUpFileSystemList(IN PFILE_SYSTEM_LIST List)
Definition: fslist.c:236
LPSTR MUIGetString(ULONG Number)
Definition: mui.c:230
Definition: typedefs.h:119
Definition: bl.h:1338
BOOLEAN QuickFormat
Definition: fslist.h:35
HANDLE ProcessHeap
Definition: servman.c:15
struct _FILE_SYSTEM_LIST * PFILE_SYSTEM_LIST
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define STRING_FORMATDISK2
Definition: mui.h:150
VOID DrawFileSystemList(IN PFILE_SYSTEM_LIST List)
Definition: fslist.c:167
struct _FILE_SYSTEM_ITEM * PFILE_SYSTEM_ITEM
#define OUT
Definition: typedefs.h:40
#define BACKGROUND_BLUE
Definition: blue.h:65
unsigned int ULONG
Definition: retypes.h:1
PFILE_SYSTEM_LIST CreateFileSystemList(IN SHORT Left, IN SHORT Top, IN BOOLEAN ForceFormat, IN PCWSTR SelectFileSystem)
Definition: fslist.c:109
ULONG Y
Definition: bl.h:1341
static LPHIST_ENTRY Top
Definition: history.c:53
VOID DestroyFileSystemList(IN PFILE_SYSTEM_LIST List)
Definition: fslist.c:149