[PRINTING]
[reactos.git] / reactos / base / applications / network / net / cmdHelpMsg.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS net command
4 * FILE: base/applications/network/net/cmdHelpMsg.c
5 * PURPOSE:
6 *
7 * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
8 */
9
10 #include "net.h"
11
12 #include <stdlib.h>
13
14 INT cmdHelpMsg(INT argc, WCHAR **argv)
15 {
16 INT i;
17 LONG errNum;
18 LPWSTR endptr;
19 // DWORD dwLength = 0;
20 LPWSTR lpBuffer;
21
22 if (argc < 3)
23 {
24 ConResPuts(StdOut, IDS_HELPMSG_SYNTAX);
25 return 1;
26 }
27
28 for (i = 2; i < argc; i++)
29 {
30 if (_wcsicmp(argv[i], L"/help") == 0)
31 {
32 ConResPuts(StdOut, IDS_HELPMSG_HELP);
33 return 1;
34 }
35 }
36
37 errNum = wcstol(argv[2], &endptr, 10);
38 if (*endptr != 0)
39 {
40 ConResPuts(StdOut, IDS_HELPMSG_SYNTAX);
41 return 1;
42 }
43
44 /* Retrieve the message string without appending extra newlines */
45 // dwLength =
46 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
47 FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
48 NULL,
49 errNum,
50 LANG_USER_DEFAULT,
51 (LPWSTR)&lpBuffer,
52 0, NULL);
53 if (lpBuffer /* && dwLength */)
54 {
55 ConPrintf(StdOut, L"\n%s\n", lpBuffer);
56 LocalFree(lpBuffer);
57 }
58 else
59 {
60 ConPrintf(StdOut, L"Unrecognized error code: %ld\n", errNum);
61 }
62
63 return 0;
64 }
65
66 /* EOF */
67