ReactOS  0.4.15-dev-341-g17c5fb8
ShellCommandHelp.cpp
Go to the documentation of this file.
1 /*
2  * regexpl - Console Registry Explorer
3  *
4  * Copyright (C) 2000-2005 Nedko Arnaudov <nedko@users.sourceforge.net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
22 // ShellCommandHelp.cpp: implementation of the CShellCommandHelp class.
23 //
25 
26 #include "ph.h"
27 #include "ShellCommandHelp.h"
28 
29 #define HELP_CMD _T("HELP")
30 #define HELP_CMD_SHORT_DESC HELP_CMD _T(" command provides help information about Registry Explorer commands.\n")
31 
33 // Construction/Destruction
35 
36 CShellCommandHelp::CShellCommandHelp(CShellCommandsLinkedList& rCommandsLinkedList):m_rCommandsLinkedList(rCommandsLinkedList)
37 {
38 }
39 
41 {
42 
43 }
44 
46 {
47  return _tcsicmp(pchCommand,HELP_CMD) == 0;
48 }
49 
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;
71  DWORD dwSize;
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 }
121 
123 {
124  return HELP_CMD_SHORT_DESC
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 }
130 
132 {
133  return HELP_CMD_SHORT_DESC;
134 }
#define FindResource
Definition: winbase.h:3633
#define _tcsicmp
Definition: xmlstorage.h:205
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
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
virtual int Execute(CConsole &rConsole, CArgumentParser &rArguments)
unsigned int BOOL
Definition: ntddk_ex.h:94
TCHAR * GetNextArgument()
CShellCommandsLinkedList & m_rCommandsLinkedList
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
smooth NULL
Definition: ftsmooth.c:416
virtual const TCHAR * GetHelpShortDescriptionString()=0
virtual ~CShellCommandHelp()
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
CShellCommand * GetNextCommand(POSITION &rPos)
unsigned long DWORD
Definition: ntddk_ex.h:95
virtual const TCHAR * GetHelpString()
#define HELP_CMD
virtual const TCHAR * GetHelpShortDescriptionString()
BOOL Write(const TCHAR *p, DWORD dwChars=0)
Definition: Console.cpp:90
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
CShellCommand * Match(const TCHAR *pchCommand)
#define isprint(c)
Definition: acclib.h:73
virtual BOOL Match(const TCHAR *pchCommand)
CShellCommandHelp(CShellCommandsLinkedList &rCommandsLinkedList)
#define HELP_CMD_SHORT_DESC
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
virtual const TCHAR * GetHelpString()=0