32a92c33465878bb1b52f06de37b38faad17f657
[reactos.git] / rosapps / applications / sysutils / regexpl / ShellCommandConnect.cpp
1 /* $Id$
2 *
3 * regexpl - Console Registry Explorer
4 *
5 * Copyright (C) 2000-2005 Nedko Arnaudov <nedko@users.sourceforge.net>
6 *
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.
11 *
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.
16 *
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.
21 */
22
23 // ShellCommandConnect.cpp: implementation of the CShellCommandConnect class.
24 //
25 //////////////////////////////////////////////////////////////////////
26
27 #include "ph.h"
28 #include "ShellCommandConnect.h"
29
30 #define CONNECT_CMD _T("CONNECT")
31 #define CONNECT_CMD_SHORT_DESC CONNECT_CMD _T(" command is used to connect to remote registry.\n")
32
33 //////////////////////////////////////////////////////////////////////
34 // Construction/Destruction
35 //////////////////////////////////////////////////////////////////////
36
37 CShellCommandConnect::CShellCommandConnect(CRegistryTree& rTree):m_rTree(rTree)
38 {
39 }
40
41 CShellCommandConnect::~CShellCommandConnect()
42 {
43 }
44
45 BOOL CShellCommandConnect::Match(const TCHAR *pchCommand)
46 {
47 return _tcsicmp(pchCommand,CONNECT_CMD) == 0;
48 }
49
50 int CShellCommandConnect::Execute(CConsole &rConsole, CArgumentParser& rArguments)
51 {
52 const TCHAR *pchArg;
53 const TCHAR *pchMachine = NULL;
54 BOOL blnHelp = FALSE;
55
56 VERIFY(m_rTree.ChangeCurrentKey(_T("\\")));
57
58 while ((pchArg = rArguments.GetNextArgument()) != NULL)
59 {
60 if ((_tcsicmp(pchArg,_T("/?")) == 0)
61 ||(_tcsicmp(pchArg,_T("-?")) == 0))
62 {
63 blnHelp = TRUE;
64 }
65 // else if ((_tcsicmp(pchArg,_T("-a")) == 0)||
66 // (_tcsicmp(pchArg,_T("/a")) == 0))
67 // {
68 // }
69 else
70 {
71 pchMachine = pchArg;
72 }
73 }
74
75 if (blnHelp)
76 rConsole.Write(GetHelpString());
77
78 if (!m_rTree.SetMachineName(pchMachine))
79 {
80 rConsole.Write(m_rTree.GetLastErrorDescription());
81 rConsole.Write(_T("\n"));
82 }
83
84 return 0;
85 }
86
87 const TCHAR * CShellCommandConnect::GetHelpString()
88 {
89 return CONNECT_CMD_SHORT_DESC
90 // _T("Syntax: ") CONNECT_CMD _T(" [Switches] [/?] machine\n\n")
91 _T("Syntax: ") CONNECT_CMD _T(" /? | MACHINE\n\n")
92 _T(" /? - This help.\n\n")
93 // _T("Switches are:\n")
94 // _T(" -a anonymous login.\n")
95 _T(" MACHINE is name/ip of the remote machine.\n")
96 _T("Example:\n")
97 _T(" ") CONNECT_CMD _T(" BOB");
98 }
99
100 const TCHAR * CShellCommandConnect::GetHelpShortDescriptionString()
101 {
102 return CONNECT_CMD_SHORT_DESC;
103 }