Skip to content

Commit 245bc3f

Browse files
committed
[NETSH] Simplify the code by naming the root context 'netsh'
-
1 parent 20d7fd7 commit 245bc3f

File tree

5 files changed

+15
-18
lines changed

5 files changed

+15
-18
lines changed

base/applications/network/netsh/context.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ CreateRootContext(VOID)
436436
{
437437
PCOMMAND_GROUP pGroup;
438438

439-
pRootContext = AddContext(NULL, NULL, NULL);
439+
pRootContext = AddContext(NULL, L"netsh", NULL);
440440
DPRINT("pRootContext: %p\n", pRootContext);
441441
if (pRootContext == NULL)
442442
return FALSE;

base/applications/network/netsh/help.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ GetContextFullName(
2121
_Inout_ LPWSTR pszBuffer,
2222
_In_ DWORD cchLength)
2323
{
24-
if (pContext->pParentContext != NULL)
24+
if (pContext != pRootContext)
2525
{
2626
GetContextFullName(pContext->pParentContext, pszBuffer, cchLength);
2727
wcscat(pszBuffer, L" ");
2828
wcscat(pszBuffer, pContext->pszContextName);
2929
}
3030
else
3131
{
32-
wcscpy(pszBuffer, L"netsh");
32+
wcscpy(pszBuffer, pContext->pszContextName);
3333
}
3434
}
3535

@@ -43,16 +43,12 @@ PrintCurrentContextHeader(
4343

4444
if (pContext == pCurrentContext)
4545
{
46-
ConPrintf(StdOut, L"\nCommands in this context:\n");
47-
}
48-
else if (pContext == pRootContext)
49-
{
50-
ConPrintf(StdOut, L"\nCommands in the netsh-context:\n");
46+
ConResPrintf(StdOut, IDS_THIS_COMMANDS);
5147
}
5248
else
5349
{
5450
GetContextFullName(pContext, szBuffer, 80);
55-
ConPrintf(StdOut, L"\nCommands in the %s-context:\n", szBuffer);
51+
ConResPrintf(StdOut, IDS_CONTEXT_COMMANDS, szBuffer);
5652
}
5753
}
5854

base/applications/network/netsh/interpreter.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,16 +224,13 @@ VOID
224224
PrintPrompt(
225225
PCONTEXT_ENTRY pContext)
226226
{
227-
if (pContext == pRootContext)
228-
{
229-
ConPuts(StdOut, L"netsh");
230-
}
231-
else
227+
if (pContext != pRootContext)
232228
{
233229
PrintPrompt(pContext->pParentContext);
234230
ConPuts(StdOut, L" ");
235-
ConPuts(StdOut, pContext->pszContextName);
236231
}
232+
233+
ConPuts(StdOut, pContext->pszContextName);
237234
}
238235

239236

base/applications/network/netsh/lang/en-US.rc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ STRINGTABLE
1212
BEGIN
1313
IDS_APP_USAGE "\nUsage: netsh [-a AliasFile] [-c Context] [-r RemoteMachine] \
1414
\n [Command | -f ScriptFile]\n"
15-
IDS_INVALID_COMMAND "The following command was not found: %ls.\n"
16-
IDS_OPEN_FAILED "The file %ls could not be openend.\n"
17-
IDS_INVALID_SYNTAX "The syntax supplied for this command is not valid. Check help for the correct syntax.\n\n"
15+
IDS_INVALID_COMMAND "The following command was not found: %ls.\n"
16+
IDS_OPEN_FAILED "The file %ls could not be openend.\n"
17+
IDS_INVALID_SYNTAX "The syntax supplied for this command is not valid. Check help for the correct syntax.\n\n"
18+
IDS_THIS_COMMANDS "\nCommands in this context:\n"
19+
IDS_CONTEXT_COMMANDS "\nCommands in the %s-context:\n"
1820
END
1921

2022
STRINGTABLE

base/applications/network/netsh/resource.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#define IDS_INVALID_COMMAND 102
1515
#define IDS_OPEN_FAILED 103
1616
#define IDS_INVALID_SYNTAX 104
17+
#define IDS_THIS_COMMANDS 105
18+
#define IDS_CONTEXT_COMMANDS 106
1719

1820
#define IDS_HELP_HEADER 200
1921
#define IDS_HELP_FOOTER 201

0 commit comments

Comments
 (0)