ReactOS 0.4.15-dev-8002-gbbb3b00
help.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for help.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static VOID GetContextFullName (_In_ PCONTEXT_ENTRY pContext, _Inout_ LPWSTR pszBuffer, _In_ DWORD cchLength)
 
static VOID HelpContext (PCONTEXT_ENTRY pContext)
 
VOID HelpGroup (PCOMMAND_GROUP pGroup)
 
DWORD WINAPI HelpCommand (LPCWSTR pwszMachine, LPWSTR *ppwcArguments, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file help.c.

Function Documentation

◆ GetContextFullName()

static VOID GetContextFullName ( _In_ PCONTEXT_ENTRY  pContext,
_Inout_ LPWSTR  pszBuffer,
_In_ DWORD  cchLength 
)
static

Definition at line 19 of file help.c.

23{
24 if (pContext->pParentContext != NULL)
25 {
26 GetContextFullName(pContext->pParentContext, pszBuffer, cchLength);
27 wcscat(pszBuffer, L" ");
28 wcscat(pszBuffer, pContext->pszContextName);
29 }
30 else
31 {
32 wcscpy(pszBuffer, L"netsh");
33 }
34}
static VOID GetContextFullName(_In_ PCONTEXT_ENTRY pContext, _Inout_ LPWSTR pszBuffer, _In_ DWORD cchLength)
Definition: help.c:19
#define NULL
Definition: types.h:112
#define L(x)
Definition: ntvdm.h:50
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)

Referenced by GetContextFullName(), and HelpContext().

◆ HelpCommand()

DWORD WINAPI HelpCommand ( LPCWSTR  pwszMachine,
LPWSTR ppwcArguments,
DWORD  dwCurrentIndex,
DWORD  dwArgCount,
DWORD  dwFlags,
LPCVOID  pvData,
BOOL pbDone 
)

Definition at line 116 of file help.c.

124{
125 PCONTEXT_ENTRY pContext;
126
128
129 pContext = pCurrentContext;
130 if (pContext == NULL)
131 {
132 DPRINT1("HelpCommand: invalid context %p\n", pContext);
133 return 1;
134 }
135
136 HelpContext(pContext);
137
139 {
142 while (pContext != NULL)
143 {
144 ConPrintf(StdOut, L" %s", pContext->pszContextName);
145 pContext = pContext->pNext;
146 }
147 ConPuts(StdOut, L"\n");
148 }
149 ConPuts(StdOut, L"\n");
150
151 return ERROR_SUCCESS;
152}
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 ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
PCONTEXT_ENTRY pCurrentContext
Definition: context.c:18
static VOID HelpContext(PCONTEXT_ENTRY pContext)
Definition: help.c:39
#define IDS_HELP_HEADER
Definition: resource.h:18
#define IDS_SUBCONTEXT_HEADER
Definition: resource.h:19
#define DPRINT1
Definition: precomp.h:8
#define ERROR_SUCCESS
Definition: deptool.c:10
Definition: precomp.h:98
PWSTR pszContextName
Definition: precomp.h:104
struct _CONTEXT_ENTRY * pSubContextHead
Definition: precomp.h:114
struct _CONTEXT_ENTRY * pNext
Definition: precomp.h:100

Referenced by CreateRootContext(), help_main(), InterpretCmd(), and main().

◆ HelpContext()

static VOID HelpContext ( PCONTEXT_ENTRY  pContext)
static

Definition at line 39 of file help.c.

41{
42 PCONTEXT_ENTRY pSubContext;
43 PCOMMAND_ENTRY pCommand;
44 PCOMMAND_GROUP pGroup;
45 WCHAR szBuffer[80];
46
47 if (pContext != pRootContext)
48 HelpContext(pContext->pParentContext);
49
50 if (pContext == pCurrentContext)
51 {
52 ConPrintf(StdOut, L"\nCommands in this context:\n");
53 }
54 else if (pContext == pRootContext)
55 {
56 ConPrintf(StdOut, L"\nCommands in the netsh-context:\n");
57 }
58 else
59 {
60 GetContextFullName(pContext, szBuffer, 80);
61 ConPrintf(StdOut, L"\nCommands in the %s-context:\n", szBuffer);
62 }
63
64 pCommand = pContext->pCommandListHead;
65 while (pCommand != NULL)
66 {
67 if (LoadStringW(pContext->hModule, pCommand->dwShortCmdHelpToken, szBuffer, 80) == 0)
68 szBuffer[0] = UNICODE_NULL;
69 ConPrintf(StdOut, L"%-15s - %s\n", pCommand->pwszCmdToken, szBuffer);
70 pCommand = pCommand->pNext;
71 }
72
73 pGroup = pContext->pGroupListHead;
74 while (pGroup != NULL)
75 {
76 if (LoadStringW(pContext->hModule, pGroup->dwShortCmdHelpToken, szBuffer, 80) == 0)
77 szBuffer[0] = UNICODE_NULL;
78 ConPrintf(StdOut, L"%-15s - %s\n", pGroup->pwszCmdGroupToken, szBuffer);
79 pGroup = pGroup->pNext;
80 }
81
82 pSubContext = pContext->pSubContextHead;
83 while (pSubContext != NULL)
84 {
85 GetContextFullName(pSubContext, szBuffer, 80);
86 ConPrintf(StdOut, L"%-15s - Changes to the \"%s\" context.\n", pSubContext->pszContextName, szBuffer);
87 pSubContext = pSubContext->pNext;
88 }
89}
PCONTEXT_ENTRY pRootContext
Definition: context.c:17
#define UNICODE_NULL
Definition: precomp.h:73
LPCWSTR pwszCmdToken
Definition: precomp.h:77
DWORD dwShortCmdHelpToken
Definition: precomp.h:79
struct _COMMAND_ENTRY * pNext
Definition: precomp.h:75
LPCWSTR pwszCmdGroupToken
Definition: precomp.h:89
struct _COMMAND_GROUP * pNext
Definition: precomp.h:87
DWORD dwShortCmdHelpToken
Definition: precomp.h:90
HMODULE hModule
Definition: precomp.h:106
struct _CONTEXT_ENTRY * pParentContext
Definition: precomp.h:102
PCOMMAND_GROUP pGroupListHead
Definition: precomp.h:111
PCOMMAND_ENTRY pCommandListHead
Definition: precomp.h:108
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by HelpCommand(), HelpContext(), MSFT_DoFuncs(), and MSFT_DoVars().

◆ HelpGroup()

VOID HelpGroup ( PCOMMAND_GROUP  pGroup)

Definition at line 93 of file help.c.

95{
96 PCOMMAND_ENTRY pCommand;
97 WCHAR szBuffer[64];
98
100
101 ConPrintf(StdOut, L"\nCommands in this context:\n");
102
103 pCommand = pGroup->pCommandListHead;
104 while (pCommand != NULL)
105 {
106 swprintf(szBuffer, L"%s %s", pGroup->pwszCmdGroupToken, pCommand->pwszCmdToken);
107 ConPrintf(StdOut, L"%-15s - ", szBuffer);
109 pCommand = pCommand->pNext;
110 }
111}
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
#define swprintf
Definition: precomp.h:40
PCOMMAND_ENTRY pCommandListHead
Definition: precomp.h:93

Referenced by InterpretCommand().