2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS help utility
4 * FILE: base/applications/cmdutils/help/help.c
5 * PURPOSE: Provide help for command-line utilities
6 * PROGRAMMERS: Lee Schroeder (spaceseel at gmail dot com)
7 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
14 #define WIN32_NO_STATUS
24 VOID
PrintResourceString(INT resID
, ...)
26 WCHAR bufSrc
[RC_STRING_MAX_SIZE
];
27 WCHAR bufFormatted
[RC_STRING_MAX_SIZE
];
28 CHAR bufFormattedOem
[RC_STRING_MAX_SIZE
];
31 va_start(args
, resID
);
33 LoadStringW(GetModuleHandleW(NULL
), resID
, bufSrc
, ARRAYSIZE(bufSrc
));
34 vswprintf(bufFormatted
, bufSrc
, args
);
35 CharToOemW(bufFormatted
, bufFormattedOem
);
36 fputs(bufFormattedOem
, stdout
);
41 BOOL
IsInternalCommand(LPCWSTR Cmd
)
47 if (!Cmd
) return FALSE
;
49 for (i
= 0; i
< ARRAYSIZE(InternalCommands
); ++i
)
51 res
= _wcsicmp(InternalCommands
[i
], Cmd
);
54 /* This is an internal command */
60 * The internal commands list is sorted in alphabetical order.
61 * We can quit the loop immediately since the current internal
62 * command is lexically greater than the command to be tested.
68 /* Command not found */
72 int wmain(int argc
, WCHAR
* argv
[])
74 WCHAR CmdLine
[CMDLINE_LENGTH
];
77 * If the user hasn't asked for specific help,
78 * then print out the list of available commands.
82 PrintResourceString(IDS_HELP1
);
83 PrintResourceString(IDS_HELP2
);
88 * Bad usage (too much options) or we use the /? switch.
89 * Display help for the help command.
91 if ((argc
> 2) || (wcscmp(argv
[1], L
"/?") == 0))
93 PrintResourceString(IDS_USAGE
);
98 * If the command is not an internal one,
99 * display an information message and exit.
101 if (!IsInternalCommand(argv
[1]))
103 PrintResourceString(IDS_NO_ENTRY
, argv
[1]);
108 * Run "<command> /?" in the current command processor.
110 StringCbPrintfW(CmdLine
, sizeof(CmdLine
), L
"%ls /?", argv
[1]);
113 return _wsystem(CmdLine
);