tangled
alpha
login
or
join now
huwcampbell.com
/
reactos
0
fork
atom
Reactos
0
fork
atom
overview
issues
pulls
pipelines
[NETSH] Sort sub-contexts in the help command
Eric Kohl
5 months ago
d0333017
5ce7d883
+41
-4
1 changed file
expand all
collapse all
unified
split
base
applications
network
netsh
help.c
+41
-4
base/applications/network/netsh/help.c
···
214
214
HeapFree(GetProcessHeap(), 0, pHelpArray);
215
215
}
216
216
217
217
+
218
218
+
static
219
219
+
int
220
220
+
SubContextCompare(
221
221
+
_In_ const void *p1,
222
222
+
_In_ const void *p2)
223
223
+
{
224
224
+
return _wcsicmp((*((PCONTEXT_ENTRY*)p1))->pszContextName, (*((PCONTEXT_ENTRY*)p2))->pszContextName);
225
225
+
}
226
226
+
227
227
+
217
228
static
218
229
VOID
219
230
PrintSubcontexts(
220
231
_In_ PCONTEXT_ENTRY pContext)
221
232
{
233
233
+
PCONTEXT_ENTRY pSubContext, *pSubContextArray = NULL;
234
234
+
DWORD dwCount, dwIndex;
235
235
+
222
236
if (pContext->pSubContextHead == NULL)
223
237
return;
224
238
239
239
+
dwCount = 0;
240
240
+
pSubContext = pContext->pSubContextHead;
241
241
+
while (pSubContext != NULL)
242
242
+
{
243
243
+
dwCount++;
244
244
+
pSubContext = pSubContext->pNext;
245
245
+
}
246
246
+
247
247
+
pSubContextArray = HeapAlloc(GetProcessHeap(), 0, dwCount * sizeof(PCONTEXT_ENTRY));
248
248
+
if (pSubContextArray == NULL)
249
249
+
return;
250
250
+
251
251
+
dwIndex = 0;
252
252
+
pSubContext = pContext->pSubContextHead;
253
253
+
while (pSubContext != NULL)
254
254
+
{
255
255
+
pSubContextArray[dwIndex] = pSubContext;
256
256
+
dwIndex++;
257
257
+
pSubContext = pSubContext->pNext;
258
258
+
}
259
259
+
260
260
+
qsort(pSubContextArray, dwCount, sizeof(PCONTEXT_ENTRY), SubContextCompare);
261
261
+
225
262
ConResPrintf(StdOut, IDS_SUBCONTEXT_HEADER);
226
226
-
pContext = pContext->pSubContextHead;
227
227
-
while (pContext != NULL)
263
263
+
for (dwIndex = 0; dwIndex < dwCount; dwIndex++)
228
264
{
229
229
-
ConPrintf(StdOut, L" %s", pContext->pszContextName);
230
230
-
pContext = pContext->pNext;
265
265
+
ConPrintf(StdOut, L" %s", pSubContextArray[dwIndex]->pszContextName);
231
266
}
232
267
ConPuts(StdOut, L"\n");
268
268
+
269
269
+
HeapFree(GetProcessHeap(), 0, pSubContextArray);
233
270
}
234
271
235
272