ReactOS 0.4.15-dev-7918-g2a2556c
CShellCommandHelp Class Reference

#include <ShellCommandHelp.h>

Inheritance diagram for CShellCommandHelp:
Collaboration diagram for CShellCommandHelp:

Public Member Functions

 CShellCommandHelp (CShellCommandsLinkedList &rCommandsLinkedList)
 
virtual ~CShellCommandHelp ()
 
virtual BOOL Match (const TCHAR *pchCommand)
 
virtual int Execute (CConsole &rConsole, CArgumentParser &rArguments)
 
virtual const TCHARGetHelpString ()
 
virtual const TCHARGetHelpShortDescriptionString ()
 
- Public Member Functions inherited from CShellCommand
 CShellCommand ()
 
virtual ~CShellCommand ()
 
virtual BOOL Match (const TCHAR *pchCommand)=0
 
virtual int Execute (CConsole &rConsole, CArgumentParser &rArguments)=0
 
virtual const TCHARGetHelpString ()=0
 
virtual const TCHARGetHelpShortDescriptionString ()=0
 

Private Attributes

CShellCommandsLinkedListm_rCommandsLinkedList
 

Detailed Description

Definition at line 12 of file ShellCommandHelp.h.

Constructor & Destructor Documentation

◆ CShellCommandHelp()

CShellCommandHelp::CShellCommandHelp ( CShellCommandsLinkedList rCommandsLinkedList)

Definition at line 36 of file ShellCommandHelp.cpp.

36 :m_rCommandsLinkedList(rCommandsLinkedList)
37{
38}
CShellCommandsLinkedList & m_rCommandsLinkedList

◆ ~CShellCommandHelp()

CShellCommandHelp::~CShellCommandHelp ( )
virtual

Definition at line 40 of file ShellCommandHelp.cpp.

41{
42
43}

Member Function Documentation

◆ Execute()

int CShellCommandHelp::Execute ( CConsole rConsole,
CArgumentParser rArguments 
)
virtual

Implements CShellCommand.

Definition at line 50 of file ShellCommandHelp.cpp.

51{
52 const TCHAR *pchArg = rArguments.GetNextArgument();
53 CShellCommand *pCommand;
54 if (pchArg == NULL)
55 {
57 while(pos)
58 {
60 rConsole.Write(pCommand->GetHelpShortDescriptionString());
61 }
62
63 return 0;
64 }
65
66 if (_tcsicmp(pchArg,_T("GPL")) == 0)
67 {
68 HRSRC hrcGPL;
69 HGLOBAL hGPL;
70 char *pchGPL;
72 if ((hrcGPL = FindResource(NULL, _T("GPL"), _T("LICENSE")))&&
73 (hGPL = LoadResource(NULL,hrcGPL))&&
74 (pchGPL = (char *)LockResource(hGPL))&&
75 (dwSize = SizeofResource(NULL,hrcGPL)))
76 {
77 // save last char
78 char pchSaved[2];
79 pchSaved[0] = pchGPL[dwSize-1];
80 pchSaved[1] = 0;
81
82 // make null-terminated string
83 pchGPL[dwSize-1] = 0;
84
85 // replace all non-printable chars except CR, LF and HTAB with spaces
86 for (DWORD i = 0; i < dwSize ; i++)
87 if ((!isprint(pchGPL[i]))&&(pchGPL[i] != '\r')&&(pchGPL[i] != '\n')&&(pchGPL[i] != '\t'))
88 pchGPL[i] = ' ';
89
90 rConsole.Write(pchGPL);
91 rConsole.Write(pchSaved);
92 }
93 else
94 {
95 rConsole.Write(_T("Internal error cannot load GPL.\n"));
96 }
97 return 0;
98 }
99
100 while (pchArg)
101 {
102 pCommand = m_rCommandsLinkedList.Match(pchArg);
103 if ((!pCommand)&&((_tcsicmp(pchArg,_T("/?")) == 0)||(_tcsicmp(pchArg,_T("-?")) == 0)))
104 pCommand = this;
105
106 if (pCommand)
107 {
108 rConsole.Write(pCommand->GetHelpString());
109 }
110 else
111 {
112 rConsole.Write(_T("HELP: Unknown command \""));
113 rConsole.Write(pchArg);
114 rConsole.Write(_T("\"\n"));
115 }
116
117 pchArg = rArguments.GetNextArgument();
118 }
119 return 0;
120}
#define isprint(c)
Definition: acclib.h:73
TCHAR * GetNextArgument()
BOOL Write(const TCHAR *p, DWORD dwChars=0)
Definition: Console.cpp:90
virtual const TCHAR * GetHelpShortDescriptionString()=0
virtual const TCHAR * GetHelpString()=0
CShellCommand * Match(const TCHAR *pchCommand)
CShellCommand * GetNextCommand(POSITION &rPos)
#define NULL
Definition: types.h:112
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
unsigned long DWORD
Definition: ntddk_ex.h:95
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
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define _T(x)
Definition: vfdio.h:22
#define FindResource
Definition: winbase.h:3793
char TCHAR
Definition: xmlstorage.h:189
#define _tcsicmp
Definition: xmlstorage.h:205

◆ GetHelpShortDescriptionString()

const TCHAR * CShellCommandHelp::GetHelpShortDescriptionString ( )
virtual

Implements CShellCommand.

Definition at line 131 of file ShellCommandHelp.cpp.

132{
133 return HELP_CMD_SHORT_DESC;
134}
#define HELP_CMD_SHORT_DESC

◆ GetHelpString()

const TCHAR * CShellCommandHelp::GetHelpString ( )
virtual

Implements CShellCommand.

Definition at line 122 of file ShellCommandHelp.cpp.

123{
125 _T("Syntax: ") HELP_CMD _T(" [<COMMAND>] [/?]\n")
126 _T(" COMMAND - Command for which help will be displayed.\n")
127 _T(" /? - This help.\n\n")
128 _T("Without parameters, command lists available commands.\n");
129}
#define HELP_CMD
int help
Definition: sort.c:20
static WCHAR available[MAX_STRING_RESOURCE_LEN]
Definition: object.c:2336
GLdouble n
Definition: glext.h:7729
GLsizei const GLubyte * commands
Definition: glext.h:11710
GLsizei GLenum const GLvoid * lists
Definition: glfuncs.h:14
#define for
Definition: utility.h:88
Definition: shell.h:41
Definition: main.c:15
static GLenum which
Definition: wgl_font.c:159

◆ Match()

BOOL CShellCommandHelp::Match ( const TCHAR pchCommand)
virtual

Implements CShellCommand.

Definition at line 45 of file ShellCommandHelp.cpp.

46{
47 return _tcsicmp(pchCommand,HELP_CMD) == 0;
48}

Member Data Documentation

◆ m_rCommandsLinkedList

CShellCommandsLinkedList& CShellCommandHelp::m_rCommandsLinkedList
private

Definition at line 22 of file ShellCommandHelp.h.

Referenced by Execute().


The documentation for this class was generated from the following files: