ReactOS 0.4.15-dev-7994-gb388cb6
help.c
Go to the documentation of this file.
1/*
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)
8 */
9
10#include <stdlib.h>
11
12#define WIN32_NO_STATUS
13#include <windef.h>
14#include <winbase.h>
15
16#include <strsafe.h>
17
18#include <conutils.h>
19
20#include "help.h"
21#include "resource.h"
22
23static BOOL
25{
26 size_t i;
27 int res;
28
29 /* Invalid command */
30 if (!Cmd) return FALSE;
31
32 for (i = 0; i < ARRAYSIZE(InternalCommands); ++i)
33 {
35 if (res == 0)
36 {
37 /* This is an internal command */
38 return TRUE;
39 }
40 else if (res > 0)
41 {
42 /*
43 * The internal commands list is sorted in alphabetical order.
44 * We can quit the loop immediately since the current internal
45 * command is lexically greater than the command to be tested.
46 */
47 break;
48 }
49 }
50
51 /* Command not found */
52 return FALSE;
53}
54
55int wmain(int argc, WCHAR* argv[])
56{
58
59 /* Initialize the Console Standard Streams */
61
62 /*
63 * If the user hasn't asked for specific help,
64 * then print out the list of available commands.
65 */
66 if (argc <= 1)
67 {
70 return 0;
71 }
72
73 /*
74 * Bad usage (too much options) or we use the /? switch.
75 * Display help for the HELP command.
76 */
77 if ((argc > 2) || (wcscmp(argv[1], L"/?") == 0))
78 {
80 return 0;
81 }
82
83 /*
84 * If the command is not an internal one,
85 * display an information message and exit.
86 */
87 if (!IsInternalCommand(argv[1]))
88 {
90 return 0;
91 }
92
93 /*
94 * Run "<command> /?" in the current command processor.
95 */
96 StringCbPrintfW(CmdLine, sizeof(CmdLine), L"%ls /?", argv[1]);
97
98 _flushall();
99 return _wsystem(CmdLine);
100}
101
102/* EOF */
static int argc
Definition: ServiceArgs.c:12
#define IDS_USAGE
Definition: resource.h:3
#define ConInitStdStreams()
Definition: fc.c:13
#define StdOut
Definition: fc.c:14
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
static BOOL IsInternalCommand(PCWSTR Cmd)
Definition: help.c:24
LPCWSTR InternalCommands[]
Definition: help.h:18
#define CMDLINE_LENGTH
Definition: help.h:12
#define IDS_NO_ENTRY
Definition: resource.h:7
#define IDS_HELP1
Definition: resource.h:4
#define IDS_HELP2
Definition: resource.h:5
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
static const WCHAR CmdLine[]
Definition: install.c:48
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint res
Definition: glext.h:9613
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
_Check_return_opt_ _CRTIMP int __cdecl _flushall(void)
Definition: file.c:893
#define argv
Definition: mplay32.c:18
#define L(x)
Definition: ntvdm.h:50
int wmain()
@ Cmd
Definition: sacdrv.h:278
_CRTIMP int __cdecl _wsystem(_In_opt_z_ const wchar_t *_Command)
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
const uint16_t * PCWSTR
Definition: typedefs.h:57
__wchar_t WCHAR
Definition: xmlstorage.h:180