sl@0
|
1 |
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// f32\etshell\ts_std.h
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <e32debug.h>
|
sl@0
|
19 |
#include <e32svr.h>
|
sl@0
|
20 |
#include <f32file.h>
|
sl@0
|
21 |
#include <f32ver.h>
|
sl@0
|
22 |
#include <f32dbg.h>
|
sl@0
|
23 |
#include <e32cons.h>
|
sl@0
|
24 |
#include <e32twin.h>
|
sl@0
|
25 |
#include <e32des16.h>
|
sl@0
|
26 |
#include "f32image.h"
|
sl@0
|
27 |
|
sl@0
|
28 |
const TUint KShellMajorVersionNumber=0;
|
sl@0
|
29 |
const TUint KShellMinorVersionNumber=1;
|
sl@0
|
30 |
const TUint KShellBuildVersionNumber=KF32BuildVersionNumber;
|
sl@0
|
31 |
const TInt KShellMaxCommandLine=0x100;
|
sl@0
|
32 |
|
sl@0
|
33 |
const TInt KDefaultHistorySize=20;
|
sl@0
|
34 |
|
sl@0
|
35 |
enum TShellPanic
|
sl@0
|
36 |
{
|
sl@0
|
37 |
EShellBadFileCopy,
|
sl@0
|
38 |
EShellBadDrivePath,
|
sl@0
|
39 |
EShellBadRelativePath,
|
sl@0
|
40 |
EShellFilePathTooBig
|
sl@0
|
41 |
};
|
sl@0
|
42 |
|
sl@0
|
43 |
enum TLineEditAction
|
sl@0
|
44 |
{
|
sl@0
|
45 |
ENoAction,
|
sl@0
|
46 |
ECommandCompletion,
|
sl@0
|
47 |
EShellCommand
|
sl@0
|
48 |
};
|
sl@0
|
49 |
|
sl@0
|
50 |
class CLineEdit : public CBase
|
sl@0
|
51 |
{
|
sl@0
|
52 |
public:
|
sl@0
|
53 |
enum TCursorType {ECursorNone=0,ECursorNormal=20,ECursorInsert=100};
|
sl@0
|
54 |
enum TEditMode {EEditOverWrite,EEditInsert};
|
sl@0
|
55 |
public:
|
sl@0
|
56 |
static CLineEdit* NewL(CConsoleBase* aConsole,TInt aMaxHistory);
|
sl@0
|
57 |
~CLineEdit();
|
sl@0
|
58 |
TLineEditAction Edit(const TDesC& aPrompt, TDes* aBuf, TBool aNewLine);
|
sl@0
|
59 |
TInt Pos() { return iPos; }
|
sl@0
|
60 |
void SetPos(TInt aPos) { iPos = aPos; }
|
sl@0
|
61 |
protected:
|
sl@0
|
62 |
CLineEdit();
|
sl@0
|
63 |
TPoint Where();
|
sl@0
|
64 |
TInt Lines();
|
sl@0
|
65 |
TInt WordLeft();
|
sl@0
|
66 |
TInt WordRight();
|
sl@0
|
67 |
void ClearLine();
|
sl@0
|
68 |
void ClearLast(TInt aCnt);
|
sl@0
|
69 |
void Recall();
|
sl@0
|
70 |
void Cursor();
|
sl@0
|
71 |
void Refresh();
|
sl@0
|
72 |
inline TDes& Buf() {return *iBuf;}
|
sl@0
|
73 |
void NewLine();
|
sl@0
|
74 |
void StoreBufferHistory();
|
sl@0
|
75 |
|
sl@0
|
76 |
private:
|
sl@0
|
77 |
CArrayFixFlat<HBufC*>* iHistory;
|
sl@0
|
78 |
CConsoleBase* iConsole; // Not owned
|
sl@0
|
79 |
TInt iMaxHistory;
|
sl@0
|
80 |
TInt iWidth;
|
sl@0
|
81 |
TInt iHeight;
|
sl@0
|
82 |
TInt iPos;
|
sl@0
|
83 |
TInt iLine;
|
sl@0
|
84 |
TInt iOrigin;
|
sl@0
|
85 |
TInt iRecall;
|
sl@0
|
86 |
TEditMode iMode;
|
sl@0
|
87 |
TDes* iBuf;
|
sl@0
|
88 |
TSize iFrameSizeChar;
|
sl@0
|
89 |
TInt iTabCount;
|
sl@0
|
90 |
};
|
sl@0
|
91 |
|
sl@0
|
92 |
class TShellCommand
|
sl@0
|
93 |
{
|
sl@0
|
94 |
public:
|
sl@0
|
95 |
enum {EASwitch=0x1,EBSwitch=0x2,ECSwitch=0x4,EDSwitch=0x8,EESwitch=0x10,
|
sl@0
|
96 |
EFSwitch=0x20,EGSwitch=0x40,EHSwitch=0x80,EISwitch=0x100,EJSwitch=0x200,
|
sl@0
|
97 |
EKSwitch=0x400,ELSwitch=0x800,EMSwitch=0x1000,ENSwitch=0x2000,EOSwitch=0x4000,
|
sl@0
|
98 |
EPSwitch=0x8000,EQSwitch=0x10000,ERSwitch=0x20000,ESSwitch=0x40000,ETSwitch=0x80000,
|
sl@0
|
99 |
EUSwitch=0x100000,EVSwitch=0x200000,EWSwitch=0x400000,EXSwitch=0x800000,EYSwitch=0x1000000,
|
sl@0
|
100 |
EZSwitch=0x2000000};
|
sl@0
|
101 |
const TPtrC iName;
|
sl@0
|
102 |
const TPtrC iHelp;
|
sl@0
|
103 |
const TPtrC iHelpDetail;
|
sl@0
|
104 |
const TUint iSwitchesSupported;
|
sl@0
|
105 |
TInt (* const iFunction)(TDes& aPath,TUint aSwitches);
|
sl@0
|
106 |
public:
|
sl@0
|
107 |
TShellCommand(const TDesC& aName,const TDesC& aHelp,const TDesC& aHelpDetail,TUint aSwitches,TInt (*aFunction)(TDes&,TUint));
|
sl@0
|
108 |
private:
|
sl@0
|
109 |
TShellCommand& operator=(TShellCommand);
|
sl@0
|
110 |
};
|
sl@0
|
111 |
|
sl@0
|
112 |
class TWord
|
sl@0
|
113 |
{
|
sl@0
|
114 |
// User types COMMAND aDes
|
sl@0
|
115 |
// TWord is initialised with aDes
|
sl@0
|
116 |
// NextWord takes aDes and locates any spaces
|
sl@0
|
117 |
// If aDes is a single word, NextWord returns the start position of the word
|
sl@0
|
118 |
// Otherwise, NextWord returns the start position of the next word
|
sl@0
|
119 |
|
sl@0
|
120 |
public:
|
sl@0
|
121 |
TWord (const TDesC& aDes);
|
sl@0
|
122 |
void Init(const TDesC& aDes);
|
sl@0
|
123 |
TInt FindNextWord(TDes& aWord);
|
sl@0
|
124 |
private:
|
sl@0
|
125 |
TInt iSpace; // Position of the first space
|
sl@0
|
126 |
TInt iNextSpace; // Position of the following space
|
sl@0
|
127 |
TPtrC iDes; // The given command line text
|
sl@0
|
128 |
public:
|
sl@0
|
129 |
TBuf<KShellMaxCommandLine> iRightString; // The residual string after a space
|
sl@0
|
130 |
TBuf<KShellMaxCommandLine> iNextWord; // Text between a space and the end of the string or another space
|
sl@0
|
131 |
};
|
sl@0
|
132 |
|
sl@0
|
133 |
|
sl@0
|
134 |
class CCliCompleter;
|
sl@0
|
135 |
|
sl@0
|
136 |
class CShell : public CBase
|
sl@0
|
137 |
{
|
sl@0
|
138 |
public:
|
sl@0
|
139 |
static CShell* NewL();
|
sl@0
|
140 |
~CShell();
|
sl@0
|
141 |
void RunL();
|
sl@0
|
142 |
void SetCurrentPath(const TDesC& aDes);
|
sl@0
|
143 |
TDes& CurrentPath();
|
sl@0
|
144 |
void SetDrivePath(const TDesC& aDes);
|
sl@0
|
145 |
static void NewLine();
|
sl@0
|
146 |
static TKeyCode OutputStringToConsole(TBool aPageSwitch,TRefByValue<const TDesC> aFmt,...);
|
sl@0
|
147 |
static TKeyCode OutputStringToConsole(TBool aPageSwitch, const TDesC& aBuf);
|
sl@0
|
148 |
static TKeyCode OutputStringToConsole(const TDesC& aNotification,TBool aPageSwitch,TRefByValue<const TDesC> aFmt,...);
|
sl@0
|
149 |
public:
|
sl@0
|
150 |
static CConsoleBase* TheConsole;
|
sl@0
|
151 |
static CFileMan* TheFileMan;
|
sl@0
|
152 |
static CCliCompleter* TheCliCompleter;
|
sl@0
|
153 |
|
sl@0
|
154 |
private:
|
sl@0
|
155 |
|
sl@0
|
156 |
/** Total numbr of built-in shell commands */
|
sl@0
|
157 |
enum {ENoShellCommands=33};
|
sl@0
|
158 |
|
sl@0
|
159 |
private:
|
sl@0
|
160 |
static void DoBanner();
|
sl@0
|
161 |
static void DoCommand(TDes& aCommand);
|
sl@0
|
162 |
static void PrintError(TInt aError);
|
sl@0
|
163 |
static void PrintHelp();
|
sl@0
|
164 |
static void PrintHelp(const TShellCommand* aCommand);
|
sl@0
|
165 |
static void ChangeDrive(TChar aDrive);
|
sl@0
|
166 |
static TInt RunBatch(TDes& aCommand);
|
sl@0
|
167 |
static TInt RunExecutable(TDes& aCommand,TBool aWaitForCompletion);
|
sl@0
|
168 |
static TKeyCode PageSwitchDisplay(const TDesC& aBuf);
|
sl@0
|
169 |
private:
|
sl@0
|
170 |
static TBuf<KMaxFileName> currentPath;
|
sl@0
|
171 |
static TBuf<KMaxFileName> drivePaths[KMaxDrives];
|
sl@0
|
172 |
static const TShellCommand iCommand[ENoShellCommands];
|
sl@0
|
173 |
static RFs TheFs;
|
sl@0
|
174 |
static CLineEdit* TheEditor;
|
sl@0
|
175 |
friend class ShellFunction;
|
sl@0
|
176 |
friend class CDllChecker;
|
sl@0
|
177 |
};
|
sl@0
|
178 |
|
sl@0
|
179 |
|
sl@0
|
180 |
class CDllChecker : public CBase
|
sl@0
|
181 |
//
|
sl@0
|
182 |
// A class for checking dependencies of executables and Dlls
|
sl@0
|
183 |
//
|
sl@0
|
184 |
{
|
sl@0
|
185 |
private:
|
sl@0
|
186 |
enum TResultCheck {EAlreadyOpen,ECouldNotOpenFile,ENotFound,EUidNotSupported,ENoImportData,EUidDifference,EFileFoundAndUidSupported};
|
sl@0
|
187 |
struct SDllInfo
|
sl@0
|
188 |
{
|
sl@0
|
189 |
TBuf8<KMaxFileName> iDllName;
|
sl@0
|
190 |
TUid iUid;
|
sl@0
|
191 |
TResultCheck iResult;
|
sl@0
|
192 |
};
|
sl@0
|
193 |
|
sl@0
|
194 |
CArrayFixFlat<SDllInfo>* iDllArray; // Array of Imports already checked
|
sl@0
|
195 |
TInt iCalls; // Number of recursive calls of GetImportDataL()
|
sl@0
|
196 |
|
sl@0
|
197 |
RFile iFile;//file object for reading data from phisical file
|
sl@0
|
198 |
TUint32 iConversionOffset;
|
sl@0
|
199 |
private:
|
sl@0
|
200 |
void GetFileNameAndUid(SDllInfo &aDllInfo, const TDesC8 &aExportName);
|
sl@0
|
201 |
TInt FindDll(TDes& aDllName,TFileName& aFileName, TPath& aPath);
|
sl@0
|
202 |
void DllAppendL(const SDllInfo& aDllInfo);
|
sl@0
|
203 |
TUint8* NextBlock(TUint8* aBlock);
|
sl@0
|
204 |
|
sl@0
|
205 |
void LoadFileInflateL(E32ImageHeaderComp* aHeader,TUint8* aRestOfFileData,TUint32 aRestOfFileSize);
|
sl@0
|
206 |
void LoadFileNoCompressL(E32ImageHeaderComp* aHeader,TUint8* aRestOfFileData,TUint32 aRestOfFileSize);
|
sl@0
|
207 |
TInt CheckUid3(TInt32 aUid3,TUid aUid);
|
sl@0
|
208 |
TInt LoadFile(TUint32 aCompression,E32ImageHeaderComp* aHeader,TUint8* aRestOfFileData,TUint32 iRestOfFileSize);
|
sl@0
|
209 |
void GetDllTableL(TUint8* aImportData,TInt aDllRefTableCount,TUint aFlags);
|
sl@0
|
210 |
public:
|
sl@0
|
211 |
CDllChecker();
|
sl@0
|
212 |
~CDllChecker();
|
sl@0
|
213 |
void ConstructL();
|
sl@0
|
214 |
void GetImportDataL(const TDesC& aFileName, TUid* aPointer);
|
sl@0
|
215 |
void ListArray();
|
sl@0
|
216 |
};
|
sl@0
|
217 |
|
sl@0
|
218 |
class ShellFunction
|
sl@0
|
219 |
{
|
sl@0
|
220 |
public:
|
sl@0
|
221 |
static CShell* TheShell;
|
sl@0
|
222 |
public:
|
sl@0
|
223 |
static TInt Attrib(TDes& aPath,TUint aSwitches);
|
sl@0
|
224 |
static TInt Cd(TDes& aPath,TUint aSwitches);
|
sl@0
|
225 |
static TInt ChkDeps(TDes& aPath,TUint aSwitches);
|
sl@0
|
226 |
static TInt ChkDsk(TDes& aPath,TUint aSwitches);
|
sl@0
|
227 |
static TInt Copy(TDes& aPath,TUint aSwitches);
|
sl@0
|
228 |
#ifndef __DATA_CAGING__
|
sl@0
|
229 |
static TInt DefaultPath(TDes& aPath,TUint aSwitches);
|
sl@0
|
230 |
#endif
|
sl@0
|
231 |
static TInt VolumeLabel(TDes& aPath,TUint aSwitches);
|
sl@0
|
232 |
static TInt Del(TDes& aPath,TUint aSwitches);
|
sl@0
|
233 |
static TInt Dir(TDes& aPath,TUint aSwitches);
|
sl@0
|
234 |
static TInt Edit(TDes& aPath,TUint aSwitches);
|
sl@0
|
235 |
static TInt Format(TDes& aPath,TUint aSwitches);
|
sl@0
|
236 |
static TInt Gobble(TDes& aPath,TUint aSwitches);
|
sl@0
|
237 |
static TInt Hexdump(TDes& aPath,TUint aSwitches);
|
sl@0
|
238 |
static TInt Md(TDes& aPath,TUint aSwitches);
|
sl@0
|
239 |
static TInt Move(TDes& aPath,TUint aSwitches);
|
sl@0
|
240 |
static TInt Ps(TDes& aPath,TUint aSwitches);
|
sl@0
|
241 |
static TInt Rename(TDes& aPath,TUint aSwitches);
|
sl@0
|
242 |
static TInt Rd(TDes& aPath,TUint aSwitches);
|
sl@0
|
243 |
static TInt Start(TDes& aProgram,TUint aSwitches);
|
sl@0
|
244 |
static TInt Time(TDes&,TUint aSwitches);
|
sl@0
|
245 |
static TInt Trace(TDes& aState,TUint aSwitches);
|
sl@0
|
246 |
static TInt Tree(TDes& aPath,TUint aSwitches);
|
sl@0
|
247 |
static TInt Type(TDes& aPath,TUint aSwitches);
|
sl@0
|
248 |
static TInt ValidName(TDes& aPath,TUint aSwitches);
|
sl@0
|
249 |
static TInt XCopy(TDes& aPath,TUint aSwitches);
|
sl@0
|
250 |
static TInt Lock(TDes& aPath, TUint aSwitches);
|
sl@0
|
251 |
static TInt Unlock(TDes& aPath, TUint aSwitches);
|
sl@0
|
252 |
static TInt Clear(TDes& aPath, TUint aSwitches);
|
sl@0
|
253 |
static TInt SetSize(TDes& aPath,TUint aSwitches);
|
sl@0
|
254 |
static TInt DebugPort(TDes& aArgs, TUint aSwitches);
|
sl@0
|
255 |
static TInt Plugin(TDes& aArgs, TUint aSwitches);
|
sl@0
|
256 |
static TInt DrvInfo(TDes& aArgs, TUint aSwitches);
|
sl@0
|
257 |
static TInt SysInfo(TDes& aArgs, TUint aSwitches);
|
sl@0
|
258 |
static TInt MountFileSystem(TDes& aArgs, TUint aSwitches);
|
sl@0
|
259 |
static TInt ConsoleEcho(TDes& aArgs, TUint aSwitches);
|
sl@0
|
260 |
static TInt RunExec(TDes& aProgram, TUint aSwitches);
|
sl@0
|
261 |
static void ParsePath(TDes& aPath);
|
sl@0
|
262 |
static TInt GetFullPath(TDes& aPath,TParse& aParse);
|
sl@0
|
263 |
static void AlignTextIntoColumns(RPointerArray<HBufC>& aText);
|
sl@0
|
264 |
static void StripQuotes(TDes& aVal);
|
sl@0
|
265 |
|
sl@0
|
266 |
private:
|
sl@0
|
267 |
static TInt ShowDirectoryTree(TDes& aPath,TUint aSwitches,TDes& aTreeGraph);
|
sl@0
|
268 |
static TBool Certain();
|
sl@0
|
269 |
static void OutputContentsToConsole(RPointerArray<HBufC>& aText,TUint aSwitches);
|
sl@0
|
270 |
static void OutputDirContentL(CDir* aDirList,RPointerArray<HBufC>& aText,TUint aSwitches);
|
sl@0
|
271 |
};
|
sl@0
|
272 |
|
sl@0
|
273 |
GLREF_D TVersion TheShellVersion;
|
sl@0
|
274 |
GLREF_C void Panic(TShellPanic anErrorCode);
|
sl@0
|
275 |
GLREF_C TInt AddRelativePath(TParse& aParse,const TDesC& aRelativePath);
|
sl@0
|
276 |
GLREF_C TInt GetFullPath(TParse& aParse,const TDesC& aPath,const TDesC& aCurrentPath);
|
sl@0
|
277 |
GLREF_C void Get16BitDllName(TDes8& aDllName,TDes& aFileName);
|
sl@0
|
278 |
|
sl@0
|
279 |
NONSHARABLE_CLASS(SimpleOverflowTruncate): public TDes16Overflow
|
sl@0
|
280 |
{
|
sl@0
|
281 |
public:
|
sl@0
|
282 |
virtual void Overflow(TDes16&)
|
sl@0
|
283 |
{
|
sl@0
|
284 |
return;
|
sl@0
|
285 |
}
|
sl@0
|
286 |
};
|