@@ -96,19 +96,6 @@ PrintShortGroupCommands(
9696}
9797
9898
99- static
100- VOID
101- PrintLongCommand (
102- _In_ PCONTEXT_ENTRY pContext ,
103- _In_ PCOMMAND_ENTRY pCommand )
104- {
105- WCHAR szBuffer [80 ];
106-
107- LoadStringW (pContext -> hModule , pCommand -> dwCmdHlpToken , szBuffer , 80 );
108- ConPrintf (StdOut , szBuffer );
109- }
110-
111-
11299static
113100int
114101HelpCompare (
@@ -227,159 +214,70 @@ PrintContext(
227214 HeapFree (GetProcessHeap (), 0 , pHelpArray );
228215}
229216
230-
231217static
232218VOID
233- PrintGroup (
234- _In_ PCONTEXT_ENTRY pContext ,
235- _In_ LPWSTR pszGroupName ,
236- _In_ BOOL bRecurse )
219+ PrintSubcontexts (
220+ _In_ PCONTEXT_ENTRY pContext )
237221{
238- PCOMMAND_GROUP pGroup ;
222+ if (pContext -> pSubContextHead == NULL )
223+ return ;
239224
240- if (bRecurse )
225+ ConResPrintf (StdOut , IDS_SUBCONTEXT_HEADER );
226+ pContext = pContext -> pSubContextHead ;
227+ while (pContext != NULL )
241228 {
242- if (pContext != pRootContext )
243- PrintGroup (pContext -> pParentContext , pszGroupName , bRecurse );
244- }
245-
246- pGroup = pContext -> pGroupListHead ;
247- while (pGroup != NULL )
248- {
249- if (_wcsicmp (pszGroupName , pGroup -> pwszCmdGroupToken ) == 0 )
250- {
251- PrintCurrentContextHeader (pContext );
252- PrintShortGroupCommands (pContext , pGroup );
253- }
254- pGroup = pGroup -> pNext ;
229+ ConPrintf (StdOut , L" %s" , pContext -> pszContextName );
230+ pContext = pContext -> pNext ;
255231 }
232+ ConPuts (StdOut , L"\n" );
256233}
257234
258235
259- static
260236VOID
261- PrintSubcontexts (
262- _In_ PCONTEXT_ENTRY pContext )
237+ PrintCommandHelp (
238+ _In_ PCONTEXT_ENTRY pContext ,
239+ _In_ PCOMMAND_ENTRY pCommand )
263240{
264- if (pCurrentContext -> pSubContextHead != NULL )
265- {
266- ConResPrintf (StdOut , IDS_SUBCONTEXT_HEADER );
267- pContext = pCurrentContext -> pSubContextHead ;
268- while (pContext != NULL )
269- {
270- ConPrintf (StdOut , L" %s" , pContext -> pszContextName );
271- pContext = pContext -> pNext ;
272- }
273- ConPuts (StdOut , L"\n" );
274- }
241+ WCHAR szBuffer [80 ];
242+
243+ LoadStringW (pContext -> hModule , pCommand -> dwCmdHlpToken , szBuffer , 80 );
244+ ConPrintf (StdOut , szBuffer );
275245}
276246
277247
278- BOOL
279- ProcessHelp (
248+ VOID
249+ PrintGroupHelp (
280250 _In_ PCONTEXT_ENTRY pContext ,
281- _In_ DWORD dwArgCount ,
282- _In_ LPWSTR * argv ,
283- _In_ DWORD dwCurrentIndex ,
284- _In_ DWORD dwHelpLevel )
251+ _In_ LPWSTR pszGroupName ,
252+ _In_ BOOL bRecurse )
285253{
286- PCONTEXT_ENTRY pSubContext ;
287- PCOMMAND_ENTRY pCommand ;
288254 PCOMMAND_GROUP pGroup ;
289255
290- DPRINT ("ProcessHelp(dwCurrentIndex %lu dwArgCount %lu dwHelpLevel %lu)\n" , dwCurrentIndex , dwArgCount , dwHelpLevel );
291-
292- if (dwHelpLevel == dwCurrentIndex )
293- {
294- ConResPrintf (StdOut , IDS_HELP_HEADER );
295- PrintContext (pContext );
296- PrintSubcontexts (pContext );
297- ConResPrintf (StdOut , IDS_HELP_FOOTER );
298- return TRUE;
299- }
300-
301- pCommand = pContext -> pCommandListHead ;
302- while (pCommand != NULL )
256+ if (bRecurse )
303257 {
304- if (_wcsicmp (argv [dwCurrentIndex ], pCommand -> pwszCmdToken ) == 0 )
305- {
306- if (dwHelpLevel == dwCurrentIndex + 1 )
307- {
308- PrintLongCommand (pContext , pCommand );
309- return TRUE;
310- }
311- }
312-
313- pCommand = pCommand -> pNext ;
258+ if (pContext != pRootContext )
259+ PrintGroupHelp (pContext -> pParentContext , pszGroupName , bRecurse );
314260 }
315261
316262 pGroup = pContext -> pGroupListHead ;
317263 while (pGroup != NULL )
318264 {
319- if (_wcsicmp (argv [ dwCurrentIndex ] , pGroup -> pwszCmdGroupToken ) == 0 )
265+ if (_wcsicmp (pszGroupName , pGroup -> pwszCmdGroupToken ) == 0 )
320266 {
321- if (dwHelpLevel == dwCurrentIndex + 1 )
322- {
323- ConResPrintf (StdOut , IDS_HELP_HEADER );
324- PrintGroup (pContext , argv [dwCurrentIndex ], (dwHelpLevel == 1 ));
325- return TRUE;
326- }
327-
328- pCommand = pGroup -> pCommandListHead ;
329- while (pCommand != NULL )
330- {
331- if ((dwArgCount > dwCurrentIndex + 1 ) && (_wcsicmp (argv [dwCurrentIndex + 1 ], pCommand -> pwszCmdToken ) == 0 ))
332- {
333- if (dwHelpLevel == dwCurrentIndex + 2 )
334- {
335- PrintLongCommand (pContext , pCommand );
336- return TRUE;
337- }
338- }
339-
340- pCommand = pCommand -> pNext ;
341- }
342-
343- // ConResPrintf(StdOut, IDS_HELP_HEADER);
344- // PrintGroup(pContext, pGroup);
345- return FALSE;
267+ PrintCurrentContextHeader (pContext );
268+ PrintShortGroupCommands (pContext , pGroup );
346269 }
347-
348270 pGroup = pGroup -> pNext ;
349271 }
350-
351- if (pContext == pCurrentContext )
352- {
353- pSubContext = pContext -> pSubContextHead ;
354- while (pSubContext != NULL )
355- {
356- if (_wcsicmp (argv [dwCurrentIndex ], pSubContext -> pszContextName ) == 0 )
357- {
358- return ProcessHelp (pSubContext ,
359- dwArgCount ,
360- argv ,
361- dwCurrentIndex + 1 ,
362- dwHelpLevel );
363- }
364-
365- pSubContext = pSubContext -> pNext ;
366- }
367- }
368-
369- return FALSE;
370272}
371273
372274
373- DWORD
374- WINAPI
375- HelpCommand (
376- LPCWSTR pwszMachine ,
377- LPWSTR * ppwcArguments ,
378- DWORD dwCurrentIndex ,
379- DWORD dwArgCount ,
380- DWORD dwFlags ,
381- LPCVOID pvData ,
382- BOOL * pbDone )
275+ VOID
276+ PrintContextHelp (
277+ _In_ PCONTEXT_ENTRY pContext )
383278{
384- return ERROR_SUCCESS ;
279+ ConResPrintf (StdOut , IDS_HELP_HEADER );
280+ PrintContext (pContext );
281+ PrintSubcontexts (pContext );
282+ ConResPrintf (StdOut , IDS_HELP_FOOTER );
385283}
0 commit comments