ReactOS 0.4.16-dev-329-g9223134
ShellCommandsLinkedList.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// ShellCommandsLinkedList.cpp: implementation of the CShellCommandsLinkedList class.
23//
25
26#include "ph.h"
28
30// Construction/Destruction
32
34{
35 m_pRoot = NULL;
36}
37
39{
40}
41
43{
44 // Create new node
45 SNode *pNewNode = new (std::nothrow) SNode;
46 if (pNewNode == NULL)
47 return;
48
49 pNewNode->m_pData = pCommand;
50
51 // add new node to the end
52 if (m_pRoot)
53 {
54 SNode *pLastNode = m_pRoot;
55
56 while (pLastNode->m_pNext)
57 pLastNode = pLastNode->m_pNext;
58
59 pLastNode->m_pNext = pNewNode;
60 }
61 else
62 {
63 m_pRoot = pNewNode;
64 }
65}
66
67int CShellCommandsLinkedList::Execute(CArgumentParser& rArgumentParser, int& nReturnValue)
68{
69 rArgumentParser.ResetArgumentIteration();
70
71 const TCHAR *pchCommand = rArgumentParser.GetNextArgument();
72
73 if (pchCommand == NULL) // empty command line
74 return -2;
75
76 int i = -1;
77
78 SNode *pNode = m_pRoot;
79
80 while(pNode)
81 {
82 i++;
83 if (pNode->m_pData->Match(pchCommand))
84 {
85 nReturnValue = pNode->m_pData->Execute(m_rConsole,rArgumentParser);
86 return i;
87 }
88 pNode = pNode->m_pNext;
89 }
90
91 return -1;
92}
93
95{
96 SNode *pNode = m_pRoot;
97
98 while(pNode)
99 {
100 if (pNode->m_pData->Match(pchCommand))
101 return pNode->m_pData;
102 pNode = pNode->m_pNext;
103 }
104
105 return NULL;
106}
107
109{
110 return (POSITION)m_pRoot;
111}
112
114{
115 CShellCommand * pCommand = ((SNode *)rPos)->m_pData;
116 rPos = (POSITION)(((SNode *)rPos)->m_pNext);
117 return pCommand;
118}
119
#define POSITION
void ResetArgumentIteration()
TCHAR * GetNextArgument()
virtual BOOL Match(const TCHAR *pchCommand)=0
virtual int Execute(CConsole &rConsole, CArgumentParser &rArguments)=0
void AddCommand(CShellCommand *pCommand)
CShellCommand * Match(const TCHAR *pchCommand)
int Execute(CArgumentParser &rArgumentParser, int &nReturnValue)
CShellCommandsLinkedList(CConsole &rConsole)
struct CShellCommandsLinkedList::SNode * m_pRoot
CShellCommand * GetNextCommand(POSITION &rPos)
#define NULL
Definition: types.h:112
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
char TCHAR
Definition: xmlstorage.h:189