ReactOS  0.4.12-dev-51-ge94618b
help.c File Reference
#include <stdlib.h>
#include <windef.h>
#include <winbase.h>
#include <strsafe.h>
#include <conutils.h>
#include "help.h"
#include "resource.h"
Include dependency graph for help.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 

Functions

static BOOL IsInternalCommand (PCWSTR Cmd)
 
int wmain (int argc, WCHAR *argv[])
 

Macro Definition Documentation

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 12 of file help.c.

Function Documentation

◆ IsInternalCommand()

static BOOL IsInternalCommand ( PCWSTR  Cmd)
static

Definition at line 24 of file help.c.

Referenced by wmain().

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  {
34  res = _wcsicmp(InternalCommands[i], Cmd);
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 }
#define TRUE
Definition: types.h:120
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
GLenum GLclampf GLint i
Definition: glfuncs.h:14
LPCWSTR InternalCommands[]
Definition: help.h:18
Definition: sacdrv.h:278
GLuint res
Definition: glext.h:9613
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

◆ wmain()

int wmain ( int  argc,
WCHAR argv[] 
)

Definition at line 55 of file help.c.

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 }
static int argc
Definition: ServiceArgs.c:12
char CmdLine[0x100]
Definition: mach.c:35
#define IDS_NO_ENTRY
Definition: resource.h:7
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CMDLINE_LENGTH
Definition: help.h:12
#define IDS_USAGE
Definition: resource.h:3
static char ** argv
Definition: ServiceArgs.c:11
#define IDS_HELP1
Definition: resource.h:4
#define ConInitStdStreams()
Definition: stream.h:122
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:781
#define IDS_HELP2
Definition: resource.h:5
_CRTIMP int __cdecl _wsystem(_In_opt_z_ const wchar_t *_Command)
static BOOL IsInternalCommand(PCWSTR Cmd)
Definition: help.c:24
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
static const WCHAR L[]
Definition: oid.c:1087
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_Check_return_opt_ _CRTIMP int __cdecl _flushall(void)
Definition: file.c:893
#define StdOut
Definition: stream.h:76