ReactOS 0.4.16-dev-1946-g52006dd
context.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for context.c:

Go to the source code of this file.

Classes

struct  _CONTEXT_STACK_ENTRY
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _CONTEXT_STACK_ENTRY CONTEXT_STACK_ENTRY
 
typedef struct _CONTEXT_STACK_ENTRYPCONTEXT_STACK_ENTRY
 

Functions

PCONTEXT_ENTRY AddContext (PCONTEXT_ENTRY pParentContext, PWSTR pszName, GUID *pGuid)
 
PCOMMAND_ENTRY AddContextCommand (PCONTEXT_ENTRY pContext, LPCWSTR pwszCmdToken, PFN_HANDLE_CMD pfnCmdHandler, DWORD dwShortCmdHelpToken, DWORD dwCmdHlpToken, DWORD dwFlags)
 
PCOMMAND_GROUP AddCommandGroup (PCONTEXT_ENTRY pContext, LPCWSTR pwszCmdGroupToken, DWORD dwShortCmdHelpToken, DWORD dwFlags)
 
PCOMMAND_ENTRY AddGroupCommand (PCOMMAND_GROUP pGroup, LPCWSTR pwszCmdToken, PFN_HANDLE_CMD pfnCmdHandler, DWORD dwShortCmdHelpToken, DWORD dwCmdHlpToken, DWORD dwFlags)
 
VOID RemoveContextFromStack (_In_ PCONTEXT_ENTRY pContextEntry)
 
VOID DeleteContext (PWSTR pszName)
 
static int ContextCompare (_In_ const void *p1, _In_ const void *p2)
 
static DWORD DumpContext (_In_ PCONTEXT_ENTRY pContext, _In_ LPCWSTR pwszMachine, _In_ LPWSTR *ppwcArguments, _In_ DWORD dwArgCount, _In_ LPCVOID pvData)
 
static DWORD CommitContext (_In_ PCONTEXT_ENTRY pContext, _In_ DWORD dwAction)
 
DWORD WINAPI UpCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI AbortCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI CommitCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI DumpCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *ppwcArguments, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI ExecCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI ExitCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI RemCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI OfflineCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI OnlineCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI PopdCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI PushdCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI SetMachineCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI SetModeCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI ShowModeCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
BOOL CreateRootContext (VOID)
 
static PCONTEXT_ENTRY FindSubContextByGuid (PCONTEXT_ENTRY pContext, const GUID *pGuid)
 
PCONTEXT_ENTRY FindContextByGuid (const GUID *pGuid)
 
DWORD WINAPI RegisterContext (_In_ const NS_CONTEXT_ATTRIBUTES *pChildContext)
 
VOID CleanupContext (VOID)
 

Variables

PCONTEXT_ENTRY pRootContext = NULL
 
PCONTEXT_ENTRY pCurrentContext = NULL
 
PCONTEXT_STACK_ENTRY pContextStackHead = NULL
 
PCONTEXT_STACK_ENTRY pContextStackTail = NULL
 
PWSTR pszMachine = NULL
 
static BOOL bOnline = TRUE
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file context.c.

Typedef Documentation

◆ CONTEXT_STACK_ENTRY

◆ PCONTEXT_STACK_ENTRY

Function Documentation

◆ AbortCommand()

DWORD WINAPI AbortCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 494 of file context.c.

502{
503 DPRINT("AbortCommand()\n");
505 return ERROR_SUCCESS;
506}
PCONTEXT_ENTRY pRootContext
Definition: context.c:26
static DWORD CommitContext(_In_ PCONTEXT_ENTRY pContext, _In_ DWORD dwAction)
Definition: context.c:405
#define ERROR_SUCCESS
Definition: deptool.c:10
@ NETSH_FLUSH
Definition: netsh.h:55
#define DPRINT
Definition: sndvol32.h:73

Referenced by CreateRootContext().

◆ AddCommandGroup()

PCOMMAND_GROUP AddCommandGroup ( PCONTEXT_ENTRY  pContext,
LPCWSTR  pwszCmdGroupToken,
DWORD  dwShortCmdHelpToken,
DWORD  dwFlags 
)

Definition at line 152 of file context.c.

157{
159
160 DPRINT("AddCommandGroup(%S %lu)\n", pwszCmdGroupToken, dwShortCmdHelpToken);
161
162 /* Allocate the entry */
164 if (pEntry == NULL)
165 return NULL;
166
167 pEntry->pwszCmdGroupToken = HeapAlloc(GetProcessHeap(),
169 (wcslen(pwszCmdGroupToken) + 1) * sizeof(WCHAR));
170 if (pEntry->pwszCmdGroupToken == NULL)
171 {
173 return NULL;
174 }
175
176 wcscpy((LPWSTR)pEntry->pwszCmdGroupToken, pwszCmdGroupToken);
177 pEntry->dwShortCmdHelpToken = dwShortCmdHelpToken;
178 pEntry->dwFlags = dwFlags;
179
180 if (pContext->pGroupListHead == NULL && pContext->pGroupListTail == NULL)
181 {
182 pContext->pGroupListHead = pEntry;
183 pContext->pGroupListTail = pEntry;
184 }
185 else
186 {
187 pEntry->pPrev = pContext->pGroupListTail;
188 pContext->pGroupListTail->pNext = pEntry;
189 pContext->pGroupListTail = pEntry;
190 }
191
192 return pEntry;
193}
wcscpy
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
struct _COMMAND_GROUP * pNext
Definition: precomp.h:94
PCOMMAND_GROUP pGroupListTail
Definition: precomp.h:124
PCOMMAND_GROUP pGroupListHead
Definition: precomp.h:123
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CreateRootContext(), and RegisterContext().

◆ AddContext()

PCONTEXT_ENTRY AddContext ( PCONTEXT_ENTRY  pParentContext,
PWSTR  pszName,
GUID pGuid 
)

Definition at line 39 of file context.c.

43{
45
46 DPRINT("AddContext(%S)\n", pszName);
47 if (pParentContext)
48 {
49 DPRINT("ParentContext %S\n", pParentContext->pszContextName);
50 }
51
52 if (pParentContext != NULL && pszName == NULL)
53 return NULL;
54
55 /* Allocate the entry */
57 if (pEntry == NULL)
58 return NULL;
59
60 /* Allocate the name buffer */
61 if (pszName != NULL)
62 {
63 pEntry->pszContextName = HeapAlloc(GetProcessHeap(),
65 (wcslen(pszName) + 1) * sizeof(WCHAR));
66 if (pEntry->pszContextName == NULL)
67 {
69 return NULL;
70 }
71
72 /* Fill the entry */
73 wcscpy(pEntry->pszContextName, pszName);
74 }
75
76 pEntry->pParentContext = pParentContext;
77 if (pGuid != NULL)
78 CopyMemory(&pEntry->Guid, pGuid, sizeof(pEntry->Guid));
79
80 /* Insert it */
81 if (pParentContext != NULL)
82 {
83 if ((pParentContext->pSubContextHead == NULL) && (pParentContext->pSubContextTail == NULL))
84 {
85 pParentContext->pSubContextHead = pEntry;
86 pParentContext->pSubContextTail = pEntry;
87 }
88 else
89 {
90 pEntry->pPrev = pParentContext->pSubContextTail;
91 pParentContext->pSubContextTail->pNext = pEntry;
92 pParentContext->pSubContextTail = pEntry;
93 }
94 }
95
96 return pEntry;
97}
#define CopyMemory
Definition: minwinbase.h:29
Definition: precomp.h:105
PWSTR pszContextName
Definition: precomp.h:112
struct _CONTEXT_ENTRY * pSubContextHead
Definition: precomp.h:126
struct _CONTEXT_ENTRY * pSubContextTail
Definition: precomp.h:127

Referenced by CreateRootContext(), and RegisterContext().

◆ AddContextCommand()

PCOMMAND_ENTRY AddContextCommand ( PCONTEXT_ENTRY  pContext,
LPCWSTR  pwszCmdToken,
PFN_HANDLE_CMD  pfnCmdHandler,
DWORD  dwShortCmdHelpToken,
DWORD  dwCmdHlpToken,
DWORD  dwFlags 
)

Definition at line 101 of file context.c.

108{
110
111 if (pfnCmdHandler == NULL)
112 return NULL;
113
114 /* Allocate the entry */
116 if (pEntry == NULL)
117 return NULL;
118
119 pEntry->pwszCmdToken = HeapAlloc(GetProcessHeap(),
121 (wcslen(pwszCmdToken) + 1) * sizeof(WCHAR));
122 if (pEntry->pwszCmdToken == NULL)
123 {
125 return NULL;
126 }
127
128 wcscpy((LPWSTR)pEntry->pwszCmdToken, pwszCmdToken);
129
130 pEntry->pfnCmdHandler = pfnCmdHandler;
131 pEntry->dwShortCmdHelpToken = dwShortCmdHelpToken;
132 pEntry->dwCmdHlpToken = dwCmdHlpToken;
133 pEntry->dwFlags = dwFlags;
134
135 if (pContext->pCommandListHead == NULL && pContext->pCommandListTail == NULL)
136 {
137 pContext->pCommandListHead = pEntry;
138 pContext->pCommandListTail = pEntry;
139 }
140 else
141 {
142 pEntry->pPrev = pContext->pCommandListTail;
143 pContext->pCommandListTail->pNext = pEntry;
144 pContext->pCommandListTail = pEntry;
145 }
146
147 return pEntry;
148}
Definition: precomp.h:80
struct _COMMAND_ENTRY * pNext
Definition: precomp.h:82
PCOMMAND_ENTRY pCommandListTail
Definition: precomp.h:121
PCOMMAND_ENTRY pCommandListHead
Definition: precomp.h:120

Referenced by CreateRootContext(), and RegisterContext().

◆ AddGroupCommand()

PCOMMAND_ENTRY AddGroupCommand ( PCOMMAND_GROUP  pGroup,
LPCWSTR  pwszCmdToken,
PFN_HANDLE_CMD  pfnCmdHandler,
DWORD  dwShortCmdHelpToken,
DWORD  dwCmdHlpToken,
DWORD  dwFlags 
)

Definition at line 197 of file context.c.

204{
206
207 if (pfnCmdHandler == NULL)
208 return NULL;
209
210 /* Allocate the entry */
212 if (pEntry == NULL)
213 return NULL;
214
215 pEntry->pwszCmdToken = HeapAlloc(GetProcessHeap(),
217 (wcslen(pwszCmdToken) + 1) * sizeof(WCHAR));
218 if (pEntry->pwszCmdToken == NULL)
219 {
221 return NULL;
222 }
223
224 wcscpy((LPWSTR)pEntry->pwszCmdToken, pwszCmdToken);
225
226 pEntry->pfnCmdHandler = pfnCmdHandler;
227 pEntry->dwShortCmdHelpToken = dwShortCmdHelpToken;
228 pEntry->dwCmdHlpToken = dwCmdHlpToken;
229 pEntry->dwFlags = dwFlags;
230
231 if (pGroup->pCommandListHead == NULL && pGroup->pCommandListTail == NULL)
232 {
233 pGroup->pCommandListHead = pEntry;
234 pGroup->pCommandListTail = pEntry;
235 }
236 else
237 {
238 pEntry->pPrev = pGroup->pCommandListTail;
239 pGroup->pCommandListTail->pNext = pEntry;
240 pGroup->pCommandListTail = pEntry;
241 }
242
243 return pEntry;
244}
PCOMMAND_ENTRY pCommandListTail
Definition: precomp.h:101
PCOMMAND_ENTRY pCommandListHead
Definition: precomp.h:100

Referenced by CreateRootContext(), and RegisterContext().

◆ CleanupContext()

VOID CleanupContext ( VOID  )

Definition at line 999 of file context.c.

1000{
1001 /* Delete the context stack */
1002
1003}

Referenced by wmain().

◆ CommitCommand()

DWORD WINAPI CommitCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 511 of file context.c.

519{
520 DPRINT("CommitCommand()\n");
522 return ERROR_SUCCESS;
523}
@ NETSH_SAVE
Definition: netsh.h:57

Referenced by CreateRootContext().

◆ CommitContext()

static DWORD CommitContext ( _In_ PCONTEXT_ENTRY  pContext,
_In_ DWORD  dwAction 
)
static

Definition at line 405 of file context.c.

408{
409 PCONTEXT_ENTRY pSubContext, *pSortArray = NULL;
410 DWORD dwCount, dwIndex;
411 DWORD dwError = ERROR_SUCCESS;
412
413 DPRINT1("CommitContext(%p %lu)\n", pContext, dwAction);
414
415 if (pContext->pfnCommitFn)
416 {
417 dwError = pContext->pfnCommitFn(dwAction);
418 if (dwError != ERROR_SUCCESS)
419 {
420 DPRINT1("Commit function failed (Error %lu)\n", dwError);
421 return dwError;
422 }
423 }
424
425 if (pContext->pSubContextHead == NULL)
426 return dwError;
427
428 /* Count the sub-contexts */
429 dwCount = 0;
430 pSubContext = pContext->pSubContextHead;
431 while (pSubContext)
432 {
433 dwCount++;
434 pSubContext = pSubContext->pNext;
435 }
436
437 /* Allocate the sort array */
438 pSortArray = HeapAlloc(GetProcessHeap(), 0, dwCount * sizeof(PCONTEXT_ENTRY));
439 if (pSortArray == NULL)
441
442 /* Fill the sort array */
443 dwIndex = 0;
444 pSubContext = pContext->pSubContextHead;
445 while (pSubContext)
446 {
447 pSortArray[dwIndex] = pSubContext;
448 dwIndex++;
449 pSubContext = pSubContext->pNext;
450 }
451
452 /* Sort the array */
453 qsort(pSortArray, dwCount, sizeof(PCONTEXT_ENTRY), ContextCompare);
454
455 /* Commit the sub-contexts */
456 for (dwIndex = 0; dwIndex < dwCount; dwIndex++)
457 {
458 dwError = CommitContext(pSortArray[dwIndex],
459 dwAction);
460 if (dwError != ERROR_SUCCESS)
461 {
462 DPRINT1("Commit function failed (Error %lu)\n", dwError);
463 break;
464 }
465 }
466
467 /* Free the sort array */
468 HeapFree(GetProcessHeap(), 0, pSortArray);
469
470 return dwError;
471}
static int ContextCompare(_In_ const void *p1, _In_ const void *p2)
Definition: context.c:316
#define DPRINT1
Definition: precomp.h:8
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _CONTEXT_ENTRY * pNext
Definition: precomp.h:107

Referenced by AbortCommand(), CommitCommand(), CommitContext(), ExitCommand(), OfflineCommand(), OnlineCommand(), and SetModeCommand().

◆ ContextCompare()

static int ContextCompare ( _In_ const void p1,
_In_ const void p2 
)
static

Definition at line 316 of file context.c.

319{
320 return ((PCONTEXT_ENTRY)p1)->ulPriority - ((PCONTEXT_ENTRY)p2)->ulPriority;
321}
struct _CONTEXT_ENTRY * PCONTEXT_ENTRY

Referenced by CommitContext(), and DumpContext().

◆ CreateRootContext()

BOOL CreateRootContext ( VOID  )

Definition at line 805 of file context.c.

806{
807 PCOMMAND_GROUP pGroup;
808
809 pRootContext = AddContext(NULL, L"netsh", NULL);
810 DPRINT("pRootContext: %p\n", pRootContext);
811 if (pRootContext == NULL)
812 return FALSE;
813
815
832
834 if (pGroup)
835 {
837 }
838
839 pGroup = AddCommandGroup(pRootContext, L"delete", IDS_HLP_GROUP_DELETE, 0);
840 if (pGroup)
841 {
843 }
844
846 if (pGroup)
847 {
850 }
851
853 if (pGroup)
854 {
858 }
859
861
862 return TRUE;
863}
DWORD WINAPI ShowAliasCommand(LPCWSTR pwszMachine, LPWSTR *argv, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: alias.c:215
DWORD WINAPI UnaliasCommand(LPCWSTR pwszMachine, LPWSTR *argv, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: alias.c:234
DWORD WINAPI AliasCommand(LPCWSTR pwszMachine, LPWSTR *argv, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: alias.c:123
PCOMMAND_GROUP AddCommandGroup(PCONTEXT_ENTRY pContext, LPCWSTR pwszCmdGroupToken, DWORD dwShortCmdHelpToken, DWORD dwFlags)
Definition: context.c:152
DWORD WINAPI SetModeCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:751
PCOMMAND_ENTRY AddContextCommand(PCONTEXT_ENTRY pContext, LPCWSTR pwszCmdToken, PFN_HANDLE_CMD pfnCmdHandler, DWORD dwShortCmdHelpToken, DWORD dwCmdHlpToken, DWORD dwFlags)
Definition: context.c:101
PCOMMAND_ENTRY AddGroupCommand(PCOMMAND_GROUP pGroup, LPCWSTR pwszCmdToken, PFN_HANDLE_CMD pfnCmdHandler, DWORD dwShortCmdHelpToken, DWORD dwCmdHlpToken, DWORD dwFlags)
Definition: context.c:197
DWORD WINAPI ExecCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:549
DWORD WINAPI CommitCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:511
DWORD WINAPI ShowModeCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:789
DWORD WINAPI AbortCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:494
DWORD WINAPI OnlineCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:621
DWORD WINAPI UpCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:476
DWORD WINAPI SetMachineCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:714
PCONTEXT_ENTRY pCurrentContext
Definition: context.c:27
DWORD WINAPI DumpCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *ppwcArguments, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:528
DWORD WINAPI PopdCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:639
PCONTEXT_ENTRY AddContext(PCONTEXT_ENTRY pParentContext, PWSTR pszName, GUID *pGuid)
Definition: context.c:39
DWORD WINAPI OfflineCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:603
DWORD WINAPI PushdCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:678
DWORD WINAPI ExitCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:569
#define IDS_HLP_POPD
Definition: resource.h:29
#define IDS_HLP_DEL_HELPER
Definition: resource.h:52
#define IDS_HLP_SHOW_MODE
Definition: resource.h:62
#define IDS_HLP_SHOW_ALIAS_EX
Definition: resource.h:59
#define IDS_HLP_GROUP_SET
Definition: resource.h:67
#define IDS_HLP_GROUP_ADD
Definition: resource.h:65
#define IDS_HLP_SHOW_ALIAS
Definition: resource.h:58
#define IDS_HLP_HELP
Definition: resource.h:25
#define IDS_HLP_DUMP
Definition: resource.h:35
#define IDS_HLP_PUSHD_EX
Definition: resource.h:32
#define IDS_HLP_EXEC_EX
Definition: resource.h:34
#define IDS_HLP_POPD_EX
Definition: resource.h:30
#define IDS_HLP_UNALIAS_EX
Definition: resource.h:48
#define IDS_HLP_DUMP_EX
Definition: resource.h:36
#define IDS_HLP_GROUP_SHOW
Definition: resource.h:68
#define IDS_HLP_EXIT
Definition: resource.h:23
#define IDS_HLP_COMMIT
Definition: resource.h:43
#define IDS_HLP_DEL_HELPER_EX
Definition: resource.h:53
#define IDS_HLP_SET_MACHINE
Definition: resource.h:54
#define IDS_HLP_OFFLINE_EX
Definition: resource.h:38
#define IDS_HLP_SET_MODE_EX
Definition: resource.h:57
#define IDS_HLP_COMMIT_EX
Definition: resource.h:44
#define IDS_HLP_ALIAS
Definition: resource.h:45
#define IDS_HLP_ONLINE
Definition: resource.h:39
#define IDS_HLP_GROUP_DELETE
Definition: resource.h:66
#define IDS_HLP_SHOW_MODE_EX
Definition: resource.h:63
#define IDS_HLP_HELP_EX
Definition: resource.h:26
#define IDS_HLP_EXEC
Definition: resource.h:33
#define IDS_HLP_UNALIAS
Definition: resource.h:47
#define IDS_HLP_PUSHD
Definition: resource.h:31
#define IDS_HLP_ONLINE_EX
Definition: resource.h:40
#define IDS_HLP_UP_EX
Definition: resource.h:28
#define IDS_HLP_SHOW_HELPER
Definition: resource.h:60
#define IDS_HLP_SET_MACHINE_EX
Definition: resource.h:55
#define IDS_HLP_ABORT_EX
Definition: resource.h:42
#define IDS_HLP_SET_MODE
Definition: resource.h:56
#define IDS_HLP_EXIT_EX
Definition: resource.h:24
#define IDS_HLP_OFFLINE
Definition: resource.h:37
#define IDS_HLP_ADD_HELPER_EX
Definition: resource.h:51
#define IDS_HLP_ALIAS_EX
Definition: resource.h:46
#define IDS_HLP_ABORT
Definition: resource.h:41
#define IDS_HLP_SHOW_HELPER_EX
Definition: resource.h:61
#define IDS_HLP_ADD_HELPER
Definition: resource.h:50
#define IDS_HLP_UP
Definition: resource.h:27
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define L(x)
Definition: resources.c:13
DWORD WINAPI ShowHelperCommand(LPCWSTR pwszMachine, LPWSTR *ppwcArguments, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: helper.c:614
DWORD WINAPI AddHelperCommand(LPCWSTR pwszMachine, LPWSTR *ppwcArguments, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: helper.c:461
DWORD WINAPI DeleteHelperCommand(LPCWSTR pwszMachine, LPWSTR *ppwcArguments, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: helper.c:493
HMODULE hModule
Definition: netsh.c:17
HMODULE hModule
Definition: precomp.h:114

Referenced by wmain().

◆ DeleteContext()

VOID DeleteContext ( PWSTR  pszName)

Definition at line 303 of file context.c.

305{
306 /* Remove the context from the stack */
307 /* RemoveContextFromStack(); */
308
309 /* Delete all commands */
310 /* Delete the context */
311}

Referenced by _Requires_lock_held_().

◆ DumpCommand()

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

Definition at line 528 of file context.c.

536{
537 DPRINT("DumpCommand()\n");
538
540 pwszMachine,
543 pvData);
544}
static DWORD DumpContext(_In_ PCONTEXT_ENTRY pContext, _In_ LPCWSTR pwszMachine, _In_ LPWSTR *ppwcArguments, _In_ DWORD dwArgCount, _In_ LPCVOID pvData)
Definition: context.c:326
_In_ LPWSTR _In_ DWORD _In_ LPCVOID pvData
Definition: netsh.h:116
_In_ LPWSTR * ppwcArguments
Definition: netsh.h:114
_In_ LPWSTR _In_ DWORD dwArgCount
Definition: netsh.h:115

Referenced by CreateRootContext().

◆ DumpContext()

static DWORD DumpContext ( _In_ PCONTEXT_ENTRY  pContext,
_In_ LPCWSTR  pwszMachine,
_In_ LPWSTR ppwcArguments,
_In_ DWORD  dwArgCount,
_In_ LPCVOID  pvData 
)
static

Definition at line 326 of file context.c.

332{
333 PCONTEXT_ENTRY pSubContext, *pSortArray = NULL;
334 DWORD dwCount, dwIndex;
335 DWORD dwError = ERROR_SUCCESS;
336
337 DPRINT("DumpContext()\n");
338
339 if (pContext->pfnDumpFn)
340 {
341 dwError = pContext->pfnDumpFn(pwszMachine,
344 pvData);
345 if (dwError != ERROR_SUCCESS)
346 {
347 DPRINT1("Dump function failed (Error %lu)\n", dwError);
348 return dwError;
349 }
350 }
351
352 if (pContext->pSubContextHead == NULL)
353 return dwError;
354
355 /* Count the sub-contexts */
356 dwCount = 0;
357 pSubContext = pContext->pSubContextHead;
358 while (pSubContext)
359 {
360 dwCount++;
361 pSubContext = pSubContext->pNext;
362 }
363
364 /* Allocate the sort array */
365 pSortArray = HeapAlloc(GetProcessHeap(), 0, dwCount * sizeof(PCONTEXT_ENTRY));
366 if (pSortArray == NULL)
368
369 /* Fill the sort array */
370 dwIndex = 0;
371 pSubContext = pContext->pSubContextHead;
372 while (pSubContext)
373 {
374 pSortArray[dwIndex] = pSubContext;
375 dwIndex++;
376 pSubContext = pSubContext->pNext;
377 }
378
379 /* Sort the array */
380 qsort(pSortArray, dwCount, sizeof(PCONTEXT_ENTRY), ContextCompare);
381
382 /* Dump the sub-contexts */
383 for (dwIndex = 0; dwIndex < dwCount; dwIndex++)
384 {
385 dwError = DumpContext(pSortArray[dwIndex],
386 pwszMachine,
389 pvData);
390 if (dwError != ERROR_SUCCESS)
391 {
392 DPRINT1("Dump function failed (Error %lu)\n", dwError);
393 break;
394 }
395 }
396
397 /* Free the sort array */
398 HeapFree(GetProcessHeap(), 0, pSortArray);
399
400 return dwError;
401}

Referenced by DumpCommand(), and DumpContext().

◆ ExecCommand()

DWORD WINAPI ExecCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 549 of file context.c.

557{
558 DPRINT("ExecCommand()\n");
559
560 if (dwArgCount - dwCurrentIndex != 1)
561 return ERROR_SHOW_USAGE;
562
564}
#define argv
Definition: mplay32.c:18
DWORD RunScript(_In_ LPCWSTR filename)
Definition: netsh.c:22
#define ERROR_SHOW_USAGE
Definition: netsh.h:22
_In_ LPWSTR _In_ DWORD dwCurrentIndex
Definition: netsh.h:139

Referenced by CreateRootContext().

◆ ExitCommand()

DWORD WINAPI ExitCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 569 of file context.c.

577{
578 if (bOnline == FALSE)
580
581 *pbDone = TRUE;
582 return ERROR_SUCCESS;
583}
static BOOL bOnline
Definition: context.c:34
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD _In_ LPCVOID _Out_ BOOL * pbDone
Definition: netsh.h:143

Referenced by CreateRootContext(), and main().

◆ FindContextByGuid()

PCONTEXT_ENTRY FindContextByGuid ( const GUID pGuid)

Definition at line 898 of file context.c.

900{
901 if (pRootContext == NULL)
902 return NULL;
903 return FindSubContextByGuid(pRootContext, pGuid);
904}
static PCONTEXT_ENTRY FindSubContextByGuid(PCONTEXT_ENTRY pContext, const GUID *pGuid)
Definition: context.c:868

Referenced by PrintHelpers(), and RegisterContext().

◆ FindSubContextByGuid()

static PCONTEXT_ENTRY FindSubContextByGuid ( PCONTEXT_ENTRY  pContext,
const GUID pGuid 
)
static

Definition at line 868 of file context.c.

871{
872 PCONTEXT_ENTRY pResultContext, pSubContext;
873
874 DPRINT("FindSubContextByGuid(%p)\n", pContext);
875 DPRINT("%lx <--> %lx\n", pContext->Guid.Data1, pGuid->Data1);
876
877 if (IsEqualGUID(&pContext->Guid, pGuid))
878 {
879 DPRINT("Found!\n");
880 return pContext;
881 }
882
883 pSubContext = pContext->pSubContextHead;
884 while (pSubContext)
885 {
886 pResultContext = FindSubContextByGuid(pSubContext, pGuid);
887 if (pResultContext)
888 return pResultContext;
889
890 pSubContext = pSubContext->pNext;
891 }
892
893 return NULL;
894}
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
GUID Guid
Definition: precomp.h:113

Referenced by FindContextByGuid(), and FindSubContextByGuid().

◆ OfflineCommand()

DWORD WINAPI OfflineCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 603 of file context.c.

611{
612 DPRINT("OfflineCommand()\n");
614 bOnline = FALSE;
615 return ERROR_SUCCESS;
616}
@ NETSH_UNCOMMIT
Definition: netsh.h:54

Referenced by CreateRootContext().

◆ OnlineCommand()

DWORD WINAPI OnlineCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 621 of file context.c.

629{
630 DPRINT("OnlineCommand()\n");
632 bOnline = TRUE;
633 return ERROR_SUCCESS;
634}
@ NETSH_COMMIT
Definition: netsh.h:53

Referenced by CreateRootContext().

◆ PopdCommand()

DWORD WINAPI PopdCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 639 of file context.c.

647{
649
650 DPRINT("PopdCommand()\n");
651
652 if (pContextStackHead == NULL)
653 return ERROR_SUCCESS;
654
656
657 pCurrentContext = pEntry->pContext;
658
660 {
663 }
664 else
665 {
666 pContextStackHead = pEntry->pNext;
668 }
669
671
672 return ERROR_SUCCESS;
673}
PCONTEXT_STACK_ENTRY pContextStackHead
Definition: context.c:29
PCONTEXT_STACK_ENTRY pContextStackTail
Definition: context.c:30
Definition: context.c:18
struct _CONTEXT_STACK_ENTRY * pPrev
Definition: context.c:19

Referenced by CreateRootContext().

◆ PushdCommand()

DWORD WINAPI PushdCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 678 of file context.c.

686{
688
689 DPRINT("PushdCommand()\n");
690
692 if (pEntry == NULL)
694
695 pEntry->pContext = pCurrentContext;
696 if (pContextStackHead == NULL)
697 {
700 }
701 else
702 {
703 pEntry->pNext = pContextStackHead;
706 }
707
708 return ERROR_SUCCESS;
709}

Referenced by CreateRootContext().

◆ RegisterContext()

DWORD WINAPI RegisterContext ( _In_ const NS_CONTEXT_ATTRIBUTES pChildContext)

Definition at line 909 of file context.c.

911{
912 PHELPER_ENTRY pHelper;
913 PCONTEXT_ENTRY pContext, pParentContext;
914 PCOMMAND_GROUP pGroup;
915 DWORD i, j;
916
917 DPRINT1("RegisterContext(%p)\n", pChildContext);
918 if (pChildContext == NULL)
919 {
920 DPRINT1("Invalid child context!\n");
922 }
923
924 if ((pChildContext->pwszContext == NULL) ||
925 (wcslen(pChildContext->pwszContext) == 0) ||
926 (wcschr(pChildContext->pwszContext, L' ') != 0) ||
927 (wcschr(pChildContext->pwszContext, L'=') != 0))
928 {
929 DPRINT1("Invalid context name!\n");
931 }
932
933 DPRINT("Name: %S\n", pChildContext->pwszContext);
934 DPRINT("Groups: %lu\n", pChildContext->ulNumGroups);
935 DPRINT("Top commands: %lu\n", pChildContext->ulNumTopCmds);
936
937 pHelper = FindHelper(&pChildContext->guidHelper, pHelperListHead);
938 DPRINT("Helper %p\n", pHelper);
939 pParentContext = pRootContext;
940 if (pHelper != NULL)
941 {
942 pParentContext = FindContextByGuid(&pHelper->ParentHelperGuid);
943 DPRINT("pParentContext %p\n", pParentContext);
944 if (pParentContext == NULL)
945 pParentContext = pRootContext;
946 }
947
948 pContext = AddContext(pParentContext, pChildContext->pwszContext, (GUID*)&pChildContext->guidHelper);
949 if (pContext != NULL)
950 {
951 pContext->pfnCommitFn = pChildContext->pfnCommitFn;
952 pContext->pfnDumpFn = pChildContext->pfnDumpFn;
953 pContext->pfnConnectFn = pChildContext->pfnConnectFn;
954 pContext->ulPriority = (pChildContext->dwFlags & CMD_FLAG_PRIORITY) ?
955 pChildContext->ulPriority : DEFAULT_CONTEXT_PRIORITY;
956
957 if ((pHelper != NULL) && (pHelper->pDllEntry != NULL))
958 {
959 pContext->hModule = pHelper->pDllEntry->hModule;
960 }
961
962 for (i = 0; i < pChildContext->ulNumTopCmds; i++)
963 {
964 AddContextCommand(pContext,
965 pChildContext->pTopCmds[i].pwszCmdToken,
966 pChildContext->pTopCmds[i].pfnCmdHandler,
967 pChildContext->pTopCmds[i].dwShortCmdHelpToken,
968 pChildContext->pTopCmds[i].dwCmdHlpToken,
969 pChildContext->pTopCmds[i].dwFlags);
970 }
971
972 /* Add command groups */
973 for (i = 0; i < pChildContext->ulNumGroups; i++)
974 {
975 pGroup = AddCommandGroup(pContext,
976 pChildContext->pCmdGroups[i].pwszCmdGroupToken,
977 pChildContext->pCmdGroups[i].dwShortCmdHelpToken,
978 pChildContext->pCmdGroups[i].dwFlags);
979 if (pGroup != NULL)
980 {
981 for (j = 0; j < pChildContext->pCmdGroups[i].ulCmdGroupSize; j++)
982 {
983 AddGroupCommand(pGroup,
984 pChildContext->pCmdGroups[i].pCmdGroup[j].pwszCmdToken,
985 pChildContext->pCmdGroups[i].pCmdGroup[j].pfnCmdHandler,
986 pChildContext->pCmdGroups[i].pCmdGroup[j].dwShortCmdHelpToken,
987 pChildContext->pCmdGroups[i].pCmdGroup[j].dwCmdHlpToken,
988 pChildContext->pCmdGroups[i].pCmdGroup[j].dwFlags);
989 }
990 }
991 }
992 }
993
994 return ERROR_SUCCESS;
995}
PCONTEXT_ENTRY FindContextByGuid(const GUID *pGuid)
Definition: context.c:898
#define wcschr
Definition: compat.h:17
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
PHELPER_ENTRY FindHelper(_In_ const GUID *pguidHelper, _In_ PHELPER_ENTRY pHelper)
Definition: helper.c:360
PHELPER_ENTRY pHelperListHead
Definition: helper.c:20
if(dx< 0)
Definition: linetemp.h:194
@ CMD_FLAG_PRIORITY
Definition: netsh.h:48
#define DEFAULT_CONTEXT_PRIORITY
Definition: netsh.h:60
PNS_CONTEXT_CONNECT_FN pfnConnectFn
Definition: precomp.h:118
ULONG ulPriority
Definition: precomp.h:115
PNS_CONTEXT_COMMIT_FN pfnCommitFn
Definition: precomp.h:116
PNS_CONTEXT_DUMP_FN pfnDumpFn
Definition: precomp.h:117
HMODULE hModule
Definition: precomp.h:57
Definition: precomp.h:62
PDLL_LIST_ENTRY pDllEntry
Definition: precomp.h:69
GUID ParentHelperGuid
Definition: precomp.h:67

Referenced by InterfaceStart(), IpStart(), and WinsockStart().

◆ RemCommand()

DWORD WINAPI RemCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 588 of file context.c.

596{
597 return ERROR_SUCCESS;
598}

◆ RemoveContextFromStack()

VOID RemoveContextFromStack ( _In_ PCONTEXT_ENTRY  pContextEntry)

Definition at line 248 of file context.c.

250{
251 PCONTEXT_STACK_ENTRY pStackEntry, pNextEntry;
252
253 if (pContextStackHead == NULL)
254 return;
255
256 pStackEntry = pContextStackHead;
257 while (1)
258 {
259 if (pStackEntry->pContext == pContextEntry)
260 {
261 if (pStackEntry == pContextStackHead && pStackEntry == pContextStackHead)
262 {
265 HeapFree(GetProcessHeap(), 0, pStackEntry);
266 return;
267 }
268 else if (pStackEntry == pContextStackHead)
269 {
270 pStackEntry->pNext->pPrev = NULL;
271 pContextStackHead = pStackEntry->pNext;
272 HeapFree(GetProcessHeap(), 0, pStackEntry);
273 pStackEntry = pContextStackHead;
274 }
275 else if (pStackEntry == pContextStackTail)
276 {
277 pStackEntry->pPrev->pNext = NULL;
278 pContextStackTail = pStackEntry->pPrev;
279 HeapFree(GetProcessHeap(), 0, pStackEntry);
280 return;
281 }
282 else
283 {
284 pNextEntry = pStackEntry->pNext;
285 pStackEntry->pPrev->pNext = pStackEntry->pNext;
286 pStackEntry->pNext->pPrev = pStackEntry->pPrev;
287 HeapFree(GetProcessHeap(), 0, pStackEntry);
288 pStackEntry = pNextEntry;
289 }
290 }
291 else
292 {
293 if (pStackEntry == pContextStackTail)
294 return;
295
296 pStackEntry = pStackEntry->pNext;
297 }
298 }
299}
PCONTEXT_ENTRY pContext
Definition: context.c:22
struct _CONTEXT_STACK_ENTRY * pNext
Definition: context.c:20

◆ SetMachineCommand()

DWORD WINAPI SetMachineCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 714 of file context.c.

722{
723 DWORD dwError = ERROR_SUCCESS;
724
725 DPRINT("SetMachineCommand(pwszMachine %S dwCurrentIndex %lu dwArgCount %lu)\n",
726 pwszMachine, dwCurrentIndex, dwArgCount);
727
728 if ((dwArgCount - dwCurrentIndex) > 1)
729 return ERROR_SHOW_USAGE;
730
731 if (pszMachine != NULL)
732 {
735 }
736
737 if ((dwArgCount - dwCurrentIndex) == 1)
738 {
739 pszMachine = HeapAlloc(GetProcessHeap(), 0, (sizeof(argv[dwCurrentIndex]) + 1) * sizeof(WCHAR));
740 if (pszMachine == NULL)
743 }
744
745 return dwError;
746}
PWSTR pszMachine
Definition: context.c:32

Referenced by CreateRootContext().

◆ SetModeCommand()

DWORD WINAPI SetModeCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 751 of file context.c.

759{
760 DWORD dwError = ERROR_SUCCESS;
761
762 DPRINT("SetModeCommand(pwszMachine %S dwCurrentIndex %lu dwArgCount %lu)\n",
763 pwszMachine, dwCurrentIndex, dwArgCount);
764
765 if ((dwArgCount - dwCurrentIndex) != 1)
766 return ERROR_SHOW_USAGE;
767
768 if (!_wcsicmp(argv[dwCurrentIndex], L"offline"))
769 {
771 bOnline = FALSE;
772 }
773 else if (!_wcsicmp(argv[dwCurrentIndex], L"online"))
774 {
776 bOnline = TRUE;
777 }
778 else
779 {
780 dwError = ERROR_INVALID_SYNTAX;
781 }
782
783 return dwError;
784}
#define ERROR_INVALID_SYNTAX
Definition: netsh.h:10
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by CreateRootContext().

◆ ShowModeCommand()

DWORD WINAPI ShowModeCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 789 of file context.c.

797{
798 DPRINT("ShowModeCommand()\n");
799 ConPuts(StdOut, bOnline ? L"online\n\n" : L"offline\n\n");
800 return ERROR_SUCCESS;
801}
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define StdOut
Definition: fc.c:14

Referenced by CreateRootContext().

◆ UpCommand()

DWORD WINAPI UpCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 476 of file context.c.

484{
487
488 return ERROR_SUCCESS;
489}
struct _CONTEXT_ENTRY * pParentContext
Definition: precomp.h:109

Referenced by CreateRootContext().

Variable Documentation

◆ bOnline

BOOL bOnline = TRUE
static

Definition at line 34 of file context.c.

Referenced by ExitCommand(), OfflineCommand(), OnlineCommand(), SetModeCommand(), and ShowModeCommand().

◆ pContextStackHead

PCONTEXT_STACK_ENTRY pContextStackHead = NULL

Definition at line 29 of file context.c.

Referenced by PopdCommand(), PushdCommand(), and RemoveContextFromStack().

◆ pContextStackTail

PCONTEXT_STACK_ENTRY pContextStackTail = NULL

Definition at line 30 of file context.c.

Referenced by PopdCommand(), PushdCommand(), and RemoveContextFromStack().

◆ pCurrentContext

◆ pRootContext

◆ pszMachine

PWSTR pszMachine = NULL