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

Go to the source code of this file.

Macros

#define NDEBUG
 

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 DeleteContext (PWSTR pszName)
 
DWORD WINAPI UpCommand (LPCWSTR pwszMachine, LPWSTR *argv, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
 
DWORD WINAPI ExitCommand (LPCWSTR pwszMachine, LPWSTR *argv, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
 
DWORD WINAPI RemCommand (LPCWSTR pwszMachine, LPWSTR *argv, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
 
BOOL CreateRootContext (VOID)
 
DWORD WINAPI RegisterContext (_In_ const NS_CONTEXT_ATTRIBUTES *pChildContext)
 

Variables

PCONTEXT_ENTRY pRootContext = NULL
 
PCONTEXT_ENTRY pCurrentContext = NULL
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file context.c.

Function Documentation

◆ AddCommandGroup()

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

Definition at line 130 of file context.c.

135{
137
138 /* Allocate the entry */
140 if (pEntry == NULL)
141 return NULL;
142
143 pEntry->pwszCmdGroupToken = HeapAlloc(GetProcessHeap(),
145 (wcslen(pwszCmdGroupToken) + 1) * sizeof(WCHAR));
146 if (pEntry->pwszCmdGroupToken == NULL)
147 {
149 return NULL;
150 }
151
152 wcscpy((LPWSTR)pEntry->pwszCmdGroupToken, pwszCmdGroupToken);
153 pEntry->dwShortCmdHelpToken = dwShortCmdHelpToken;
154 pEntry->dwFlags = dwFlags;
155
156 if (pContext->pGroupListHead == NULL && pContext->pGroupListTail == NULL)
157 {
158 pContext->pGroupListHead = pEntry;
159 pContext->pGroupListTail = pEntry;
160 }
161 else
162 {
163 pEntry->pPrev = pContext->pGroupListTail;
164 pContext->pGroupListTail->pNext = pEntry;
165 pContext->pGroupListTail = pEntry;
166 }
167
168 return pEntry;
169}
#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)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
struct _COMMAND_GROUP * pNext
Definition: precomp.h:87
PCOMMAND_GROUP pGroupListTail
Definition: precomp.h:112
PCOMMAND_GROUP pGroupListHead
Definition: precomp.h:111
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
__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 23 of file context.c.

27{
29
30 if (pParentContext != NULL && pszName == NULL)
31 return NULL;
32
33 /* Allocate the entry */
35 if (pEntry == NULL)
36 return NULL;
37
38 /* Allocate the name buffer */
39 if (pszName != NULL)
40 {
41 pEntry->pszContextName = HeapAlloc(GetProcessHeap(),
43 (wcslen(pszName) + 1) * sizeof(WCHAR));
44 if (pEntry->pszContextName == NULL)
45 {
47 return NULL;
48 }
49
50 /* Fill the entry */
51 wcscpy(pEntry->pszContextName, pszName);
52 }
53
54 pEntry->pParentContext = pParentContext;
55 if (pGuid != NULL)
56 CopyMemory(&pEntry->Guid, pGuid, sizeof(pEntry->Guid));
57
58 /* Insert it */
59 if (pParentContext != NULL)
60 {
61 if (pParentContext->pSubContextHead == NULL && pParentContext->pSubContextTail == NULL)
62 {
63 pParentContext->pSubContextHead = pEntry;
64 pParentContext->pSubContextTail = pEntry;
65 }
66 else
67 {
68 pEntry->pPrev = pParentContext->pSubContextTail;
69 pParentContext->pSubContextTail->pNext = pEntry;
70 pParentContext->pSubContextTail = pEntry;
71 }
72 }
73
74 return pEntry;
75}
Definition: precomp.h:98
struct _CONTEXT_ENTRY * pSubContextHead
Definition: precomp.h:114
struct _CONTEXT_ENTRY * pSubContextTail
Definition: precomp.h:115
#define CopyMemory
Definition: winbase.h:1735

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 79 of file context.c.

86{
88
89 if (pfnCmdHandler == NULL)
90 return NULL;
91
92 /* Allocate the entry */
94 if (pEntry == NULL)
95 return NULL;
96
97 pEntry->pwszCmdToken = HeapAlloc(GetProcessHeap(),
99 (wcslen(pwszCmdToken) + 1) * sizeof(WCHAR));
100 if (pEntry->pwszCmdToken == NULL)
101 {
103 return NULL;
104 }
105
106 wcscpy((LPWSTR)pEntry->pwszCmdToken, pwszCmdToken);
107
108 pEntry->pfnCmdHandler = pfnCmdHandler;
109 pEntry->dwShortCmdHelpToken = dwShortCmdHelpToken;
110 pEntry->dwCmdHlpToken = dwCmdHlpToken;
111 pEntry->dwFlags = dwFlags;
112
113 if (pContext->pCommandListHead == NULL && pContext->pCommandListTail == NULL)
114 {
115 pContext->pCommandListHead = pEntry;
116 pContext->pCommandListTail = pEntry;
117 }
118 else
119 {
120 pEntry->pPrev = pContext->pCommandListTail;
121 pContext->pCommandListTail->pNext = pEntry;
122 pContext->pCommandListTail = pEntry;
123 }
124
125 return pEntry;
126}
Definition: precomp.h:73
struct _COMMAND_ENTRY * pNext
Definition: precomp.h:75
PCOMMAND_ENTRY pCommandListTail
Definition: precomp.h:109
PCOMMAND_ENTRY pCommandListHead
Definition: precomp.h:108

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 173 of file context.c.

180{
182
183 if (pfnCmdHandler == NULL)
184 return NULL;
185
186 /* Allocate the entry */
188 if (pEntry == NULL)
189 return NULL;
190
191 pEntry->pwszCmdToken = HeapAlloc(GetProcessHeap(),
193 (wcslen(pwszCmdToken) + 1) * sizeof(WCHAR));
194 if (pEntry->pwszCmdToken == NULL)
195 {
197 return NULL;
198 }
199
200 wcscpy((LPWSTR)pEntry->pwszCmdToken, pwszCmdToken);
201
202 pEntry->pfnCmdHandler = pfnCmdHandler;
203 pEntry->dwShortCmdHelpToken = dwShortCmdHelpToken;
204 pEntry->dwCmdHlpToken = dwCmdHlpToken;
205 pEntry->dwFlags = dwFlags;
206
207 if (pGroup->pCommandListHead == NULL && pGroup->pCommandListTail == NULL)
208 {
209 pGroup->pCommandListHead = pEntry;
210 pGroup->pCommandListTail = pEntry;
211 }
212 else
213 {
214 pEntry->pPrev = pGroup->pCommandListTail;
215 pGroup->pCommandListTail->pNext = pEntry;
216 pGroup->pCommandListTail = pEntry;
217 }
218
219 return pEntry;
220}
PCOMMAND_ENTRY pCommandListTail
Definition: precomp.h:94
PCOMMAND_ENTRY pCommandListHead
Definition: precomp.h:93

Referenced by CreateRootContext().

◆ CreateRootContext()

BOOL CreateRootContext ( VOID  )

Definition at line 282 of file context.c.

283{
284 PCOMMAND_GROUP pGroup;
285
287 DPRINT1("pRootContext: %p\n", pRootContext);
288 if (pRootContext == NULL)
289 return FALSE;
290
292
299
301 if (pGroup)
302 {
304 }
305
306 pGroup = AddCommandGroup(pRootContext, L"delete", IDS_HLP_GROUP_DELETE, 0);
307 if (pGroup)
308 {
310 }
311
313 if (pGroup)
314 {
316 }
317
319
320 return TRUE;
321}
PCOMMAND_GROUP AddCommandGroup(PCONTEXT_ENTRY pContext, LPCWSTR pwszCmdGroupToken, DWORD dwShortCmdHelpToken, DWORD dwFlags)
Definition: context.c:130
PCOMMAND_ENTRY AddContextCommand(PCONTEXT_ENTRY pContext, LPCWSTR pwszCmdToken, PFN_HANDLE_CMD pfnCmdHandler, DWORD dwShortCmdHelpToken, DWORD dwCmdHlpToken, DWORD dwFlags)
Definition: context.c:79
PCOMMAND_ENTRY AddGroupCommand(PCOMMAND_GROUP pGroup, LPCWSTR pwszCmdToken, PFN_HANDLE_CMD pfnCmdHandler, DWORD dwShortCmdHelpToken, DWORD dwCmdHlpToken, DWORD dwFlags)
Definition: context.c:173
PCONTEXT_ENTRY pRootContext
Definition: context.c:17
PCONTEXT_ENTRY pCurrentContext
Definition: context.c:18
DWORD WINAPI UpCommand(LPCWSTR pwszMachine, LPWSTR *argv, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: context.c:234
PCONTEXT_ENTRY AddContext(PCONTEXT_ENTRY pParentContext, PWSTR pszName, GUID *pGuid)
Definition: context.c:23
DWORD WINAPI ExitCommand(LPCWSTR pwszMachine, LPWSTR *argv, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: context.c:252
DWORD WINAPI HelpCommand(LPCWSTR pwszMachine, LPWSTR *ppwcArguments, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: help.c:116
#define IDS_HLP_DEL_HELPER
Definition: resource.h:30
#define IDS_HLP_GROUP_ADD
Definition: resource.h:35
#define IDS_HLP_HELP
Definition: resource.h:23
#define IDS_HLP_GROUP_SHOW
Definition: resource.h:37
#define IDS_HLP_EXIT
Definition: resource.h:21
#define IDS_HLP_DEL_HELPER_EX
Definition: resource.h:31
#define IDS_HLP_GROUP_DELETE
Definition: resource.h:36
#define IDS_HLP_HELP_EX
Definition: resource.h:24
#define IDS_HLP_UP_EX
Definition: resource.h:26
#define IDS_HLP_SHOW_HELPER
Definition: resource.h:32
#define IDS_HLP_EXIT_EX
Definition: resource.h:22
#define IDS_HLP_ADD_HELPER_EX
Definition: resource.h:29
#define IDS_HLP_SHOW_HELPER_EX
Definition: resource.h:33
#define IDS_HLP_ADD_HELPER
Definition: resource.h:28
#define IDS_HLP_UP
Definition: resource.h:25
#define DPRINT1
Definition: precomp.h:8
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD WINAPI ShowHelperCommand(LPCWSTR pwszMachine, LPWSTR *ppwcArguments, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: helper.c:573
DWORD WINAPI AddHelperCommand(LPCWSTR pwszMachine, LPWSTR *ppwcArguments, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: helper.c:425
DWORD WINAPI DeleteHelperCommand(LPCWSTR pwszMachine, LPWSTR *ppwcArguments, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: helper.c:457
#define L(x)
Definition: ntvdm.h:50
HMODULE hModule
Definition: precomp.h:106
#define GetModuleHandle
Definition: winbase.h:3852

Referenced by wmain().

◆ DeleteContext()

VOID DeleteContext ( PWSTR  pszName)

Definition at line 224 of file context.c.

226{
227 /* Delete all commands */
228 /* Delete the context */
229}

Referenced by _Requires_lock_held_().

◆ ExitCommand()

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

Definition at line 252 of file context.c.

260{
261 *pbDone = TRUE;
262 return 0;
263}

Referenced by CreateRootContext(), and main().

◆ RegisterContext()

DWORD WINAPI RegisterContext ( _In_ const NS_CONTEXT_ATTRIBUTES pChildContext)

Definition at line 326 of file context.c.

328{
329 PCONTEXT_ENTRY pContext;
330 DWORD i;
331
332 DPRINT1("RegisterContext(%p)\n", pChildContext);
333 if (pChildContext == NULL)
334 {
335 DPRINT1("Invalid child context!\n");
337 }
338
339 if ((pChildContext->pwszContext == NULL) ||
340 (wcslen(pChildContext->pwszContext) == 0) ||
341 (wcschr(pChildContext->pwszContext, L' ') != 0) ||
342 (wcschr(pChildContext->pwszContext, L'=') != 0))
343 {
344 DPRINT1("Invalid context name!\n");
346 }
347
348 DPRINT1("Name: %S\n", pChildContext->pwszContext);
349
350 pContext = AddContext(pRootContext, pChildContext->pwszContext, (GUID*)&pChildContext->guidHelper);
351 if (pContext != NULL)
352 {
353 for (i = 0; i < pChildContext->ulNumTopCmds; i++)
354 {
355 AddContextCommand(pContext,
356 pChildContext->pTopCmds[i].pwszCmdToken,
357 pChildContext->pTopCmds[i].pfnCmdHandler,
358 pChildContext->pTopCmds[i].dwShortCmdHelpToken,
359 pChildContext->pTopCmds[i].dwCmdHlpToken,
360 pChildContext->pTopCmds[i].dwFlags);
361 }
362
363 /* Add command groups */
364 for (i = 0; i < pChildContext->ulNumGroups; i++)
365 {
366 AddCommandGroup(pContext,
367 pChildContext->pCmdGroups[i].pwszCmdGroupToken,
368 pChildContext->pCmdGroups[i].dwShortCmdHelpToken,
369 pChildContext->pCmdGroups[i].dwFlags);
370 }
371 }
372
373 return ERROR_SUCCESS;
374}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define wcschr
Definition: compat.h:17
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
unsigned long DWORD
Definition: ntddk_ex.h:95
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

◆ RemCommand()

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

Definition at line 268 of file context.c.

276{
277 return 0;
278}

◆ UpCommand()

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

Definition at line 234 of file context.c.

242{
245
246 return 0;
247}
struct _CONTEXT_ENTRY * pParentContext
Definition: precomp.h:102

Referenced by CreateRootContext().

Variable Documentation

◆ pCurrentContext

◆ pRootContext