3 * regexpl - Console Registry Explorer
5 * Copyright (C) 2000-2005 Nedko Arnaudov <nedko@users.sourceforge.net>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 // ShellCommandHelp.cpp: implementation of the CShellCommandHelp class.
25 //////////////////////////////////////////////////////////////////////
28 #include "ShellCommandHelp.h"
30 #define HELP_CMD _T("HELP")
31 #define HELP_CMD_SHORT_DESC HELP_CMD _T(" command provides help information about Registry Explorer commands.\n")
33 //////////////////////////////////////////////////////////////////////
34 // Construction/Destruction
35 //////////////////////////////////////////////////////////////////////
37 CShellCommandHelp::CShellCommandHelp(CShellCommandsLinkedList
& rCommandsLinkedList
):m_rCommandsLinkedList(rCommandsLinkedList
)
41 CShellCommandHelp::~CShellCommandHelp()
46 BOOL
CShellCommandHelp::Match(const TCHAR
*pchCommand
)
48 return _tcsicmp(pchCommand
,HELP_CMD
) == 0;
51 int CShellCommandHelp::Execute(CConsole
&rConsole
, CArgumentParser
& rArguments
)
53 const TCHAR
*pchArg
= rArguments
.GetNextArgument();
54 CShellCommand
*pCommand
;
57 POSITION pos
= m_rCommandsLinkedList
.GetFirstCommandPosition();
60 pCommand
= m_rCommandsLinkedList
.GetNextCommand(pos
);
61 rConsole
.Write(pCommand
->GetHelpShortDescriptionString());
67 if (_tcsicmp(pchArg
,_T("GPL")) == 0)
73 if ((hrcGPL
= FindResource(NULL
, _T("GPL"), _T("LICENSE")))&&
74 (hGPL
= LoadResource(NULL
,hrcGPL
))&&
75 (pchGPL
= (char *)LockResource(hGPL
))&&
76 (dwSize
= SizeofResource(NULL
,hrcGPL
)))
80 pchSaved
[0] = pchGPL
[dwSize
-1];
83 // make null-terminated string
86 // replace all non-printable chars except CR, LF and HTAB with spaces
87 for (DWORD i
= 0; i
< dwSize
; i
++)
88 if ((!isprint(pchGPL
[i
]))&&(pchGPL
[i
] != '\r')&&(pchGPL
[i
] != '\n')&&(pchGPL
[i
] != '\t'))
91 rConsole
.Write(pchGPL
);
92 rConsole
.Write(pchSaved
);
96 rConsole
.Write(_T("Internal error cannot load GPL.\n"));
103 pCommand
= m_rCommandsLinkedList
.Match(pchArg
);
104 if ((!pCommand
)&&((_tcsicmp(pchArg
,_T("/?")) == 0)||(_tcsicmp(pchArg
,_T("-?")) == 0)))
109 rConsole
.Write(pCommand
->GetHelpString());
113 rConsole
.Write(_T("HELP: Unknown command \""));
114 rConsole
.Write(pchArg
);
115 rConsole
.Write(_T("\"\n"));
118 pchArg
= rArguments
.GetNextArgument();
123 const TCHAR
* CShellCommandHelp::GetHelpString()
125 return HELP_CMD_SHORT_DESC
126 _T("Syntax: ") HELP_CMD
_T(" [<COMMAND>] [/?]\n")
127 _T(" COMMAND - Command for which help will be displayed.\n")
128 _T(" /? - This help.\n\n")
129 _T("Without parameters, command lists available commands.\n");
132 const TCHAR
* CShellCommandHelp::GetHelpShortDescriptionString()
134 return HELP_CMD_SHORT_DESC
;