ReactOS 0.4.16-dev-2104-gb84fa49
help.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/help.c
5 * PURPOSE: Manages all the partitions of the OS in an interactive way.
6 * PROGRAMMERS: Lee Schroeder
7 */
8
9#include "diskpart.h"
10
11/*
12 * HelpCommandList():
13 * shows all the available commands and basic descriptions for diskpart
14 */
15VOID
17{
18 PCOMMAND cmdptr;
19 WCHAR szFormat[64];
20 WCHAR szOutput[256];
21
23
24 /* Print the header information */
26 ConPuts(StdOut, L"\n");
27
28 /* List all the commands and the basic descriptions */
29 for (cmdptr = cmds; cmdptr->cmd1; cmdptr++)
30 {
31 if ((cmdptr->cmd1 != NULL) &&
32 (cmdptr->cmd2 == NULL) &&
33 (cmdptr->cmd3 == NULL) &&
34 (cmdptr->help != IDS_NONE))
35 {
36 K32LoadStringW(GetModuleHandle(NULL), cmdptr->help, szOutput, ARRAYSIZE(szOutput));
37 ConPrintf(StdOut, szFormat, cmdptr->cmd1, szOutput);
38 }
39 }
40
41 ConPuts(StdOut, L"\n");
42}
43
44
47 PCOMMAND pCommand)
48{
49 PCOMMAND cmdptr;
50 BOOL bSubCommands = FALSE;
51 WCHAR szFormat[64];
52 WCHAR szOutput[256];
53
55
56 ConPuts(StdOut, L"\n");
57
58 /* List all the commands and the basic descriptions */
59 for (cmdptr = cmds; cmdptr->cmd1; cmdptr++)
60 {
61 if (pCommand->cmd1 != NULL && pCommand->cmd2 == NULL && pCommand->cmd3 == NULL)
62 {
63 if ((cmdptr->cmd1 != NULL && _wcsicmp(pCommand->cmd1, cmdptr->cmd1) == 0) &&
64 (cmdptr->cmd2 != NULL) &&
65 (cmdptr->cmd3 == NULL) &&
66 (cmdptr->help != IDS_NONE))
67 {
68 K32LoadStringW(GetModuleHandle(NULL), cmdptr->help, szOutput, ARRAYSIZE(szOutput));
69 ConPrintf(StdOut, szFormat, cmdptr->cmd2, szOutput);
70 bSubCommands = TRUE;
71 }
72 }
73 else if (pCommand->cmd1 != NULL && pCommand->cmd2 != NULL && pCommand->cmd3 == NULL)
74 {
75 if ((cmdptr->cmd1 != NULL && _wcsicmp(pCommand->cmd1, cmdptr->cmd1) == 0) &&
76 (cmdptr->cmd2 != NULL && _wcsicmp(pCommand->cmd2, cmdptr->cmd2) == 0) &&
77 (cmdptr->cmd3 != NULL) &&
78 (cmdptr->help != IDS_NONE))
79 {
80 K32LoadStringW(GetModuleHandle(NULL), cmdptr->help, szOutput, ARRAYSIZE(szOutput));
81 ConPrintf(StdOut, szFormat, cmdptr->cmd3, szOutput);
82 bSubCommands = TRUE;
83 }
84 }
85 else if (pCommand->cmd1 != NULL && pCommand->cmd2 != NULL && pCommand->cmd3 != NULL)
86 {
87 if ((cmdptr->cmd1 != NULL && _wcsicmp(pCommand->cmd1, cmdptr->cmd1) == 0) &&
88 (cmdptr->cmd2 != NULL && _wcsicmp(pCommand->cmd2, cmdptr->cmd2) == 0) &&
89 (cmdptr->cmd3 != NULL && _wcsicmp(pCommand->cmd3, cmdptr->cmd3) == 0) &&
90 (cmdptr->help_detail != MSG_NONE))
91 {
94 NULL,
95 cmdptr->help_detail,
97 bSubCommands = TRUE;
98 }
99 }
100 }
101
102 if ((bSubCommands == FALSE) && (pCommand->help_detail != MSG_NONE))
103 {
106 NULL,
107 pCommand->help_detail,
109 }
110
111 ConPuts(StdOut, L"\n");
112
113 return EXIT_SUCCESS;
114}
115
116
117/* help_main(char *arg):
118 * main entry point for the help command. Gives help to users who needs it.
119 */
122 _In_ INT argc,
123 _In_ PWSTR *argv)
124{
125 PCOMMAND cmdptr;
126 PCOMMAND cmdptr1 = NULL;
127 PCOMMAND cmdptr2 = NULL;
128 PCOMMAND cmdptr3 = NULL;
129
130 if (argc == 1)
131 {
133 return EXIT_SUCCESS;
134 }
135
136 /* Scan internal command table */
137 for (cmdptr = cmds; cmdptr->cmd1; cmdptr++)
138 {
139 if ((cmdptr1 == NULL) &&
140 (cmdptr->cmd1 != NULL && _wcsicmp(argv[1], cmdptr->cmd1) == 0))
141 {
142 cmdptr1 = cmdptr;
143 }
144
145 if ((cmdptr2 == NULL) &&
146 (argc >= 3) &&
147 (cmdptr->cmd1 != NULL && _wcsicmp(argv[1], cmdptr->cmd1) == 0) &&
148 (cmdptr->cmd2 != NULL && _wcsicmp(argv[2], cmdptr->cmd2) == 0))
149 {
150 cmdptr2 = cmdptr;
151 }
152
153 if ((cmdptr3 == NULL) &&
154 (argc >= 4) &&
155 (cmdptr->cmd1 != NULL && _wcsicmp(argv[1], cmdptr->cmd1) == 0) &&
156 (cmdptr->cmd2 != NULL && _wcsicmp(argv[2], cmdptr->cmd2) == 0) &&
157 (cmdptr->cmd3 != NULL && _wcsicmp(argv[3], cmdptr->cmd3) == 0))
158 {
159 cmdptr3 = cmdptr;
160 }
161 }
162
163 if (cmdptr3 != NULL)
164 {
165 return HelpCommand(cmdptr3);
166 }
167 else if (cmdptr2 != NULL)
168 {
169 return HelpCommand(cmdptr2);
170 }
171 else if (cmdptr1 != NULL)
172 {
173 return HelpCommand(cmdptr1);
174 }
175
177
178 return EXIT_SUCCESS;
179}
static int argc
Definition: ServiceArgs.c:12
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
void ConPrintf(FILE *fp, LPCWSTR psz,...)
Definition: fc.c:20
#define StdOut
Definition: fc.c:14
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
#define IDS_NONE
Definition: resource.h:144
COMMAND cmds[]
Definition: main.c:21
EXIT_CODE HelpCommand(PCOMMAND pCommand)
Definition: help.c:46
VOID HelpCommandList(VOID)
Definition: help.c:16
EXIT_CODE help_main(_In_ INT argc, _In_ PWSTR *argv)
Definition: help.c:121
#define IDS_APP_HEADER
Definition: resource.h:14
#define MSG_NONE
Definition: resource.h:12
#define IDS_HELP_FORMAT_STRING
Definition: resource.h:94
enum _EXIT_CODE EXIT_CODE
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:159
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
#define argv
Definition: mplay32.c:18
#define _In_
Definition: no_sal2.h:158
INT ConMsgPuts(IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId)
Definition: outstream.c:837
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
INT WINAPI K32LoadStringW(IN HINSTANCE hInstance OPTIONAL, IN UINT uID, OUT LPWSTR lpBuffer, IN INT nBufferMax)
Definition: utils.c:173
Definition: main.c:15
INT help
Definition: diskpart.h:90
PWSTR cmd3
Definition: diskpart.h:88
DWORD help_detail
Definition: diskpart.h:91
PWSTR cmd2
Definition: diskpart.h:87
PWSTR cmd1
Definition: diskpart.h:86
#define LANG_USER_DEFAULT
Definition: tnerror.cpp:50
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
#define GetModuleHandle
Definition: winbase.h:3576
#define FORMAT_MESSAGE_FROM_HMODULE
Definition: winbase.h:399
__wchar_t WCHAR
Definition: xmlstorage.h:180