userlibandfileserver/fileserver/etshell/ts_com.cpp
branchRCL_3
changeset 43 c1f20ce4abcf
parent 42 a179b74831c9
child 44 3e88ff8f41d5
--- a/userlibandfileserver/fileserver/etshell/ts_com.cpp	Thu Aug 19 11:14:22 2010 +0300
+++ b/userlibandfileserver/fileserver/etshell/ts_com.cpp	Tue Aug 31 16:34:26 2010 +0300
@@ -42,6 +42,7 @@
 //	lint -e40,e30
 const TShellCommand CShell::iCommand[ENoShellCommands]=
 	{
+//	TShellCommand(_L("BLANK"),_L("Help"),_L("-?"),TShellCommand::EDSwitch,ShellFunction::BLANK),
 	TShellCommand(_L("ATTRIB"),_L("Displays or changes file attributes"),_L("[drive:][path][filename] [+R | -R] [+H |-H] [+S | -S] [+A | -A] [/p]\n\n  /p - Pause after each screen of information"), TShellCommand::EPSwitch, ShellFunction::Attrib),
 	TShellCommand(_L("CD"),_L("Change the current directory for a drive"),_L("[path] [/d]\n\n  /d - Change drive"),TShellCommand::EDSwitch,ShellFunction::Cd),
 	TShellCommand(_L("CHKDEPS"),_L("Check the dependencies of an executable or a Dll (ARM only)"),_L("[Filename.EXE] or [Filename.DLL]"),0,ShellFunction::ChkDeps),
@@ -49,6 +50,7 @@
 	TShellCommand(_L("COPY"),_L("Copy one (or more) file(s), overwriting existing one(s)"),_L("source [destination]"),TShellCommand::ESSwitch,ShellFunction::Copy),
 	TShellCommand(_L("DEL"),_L("Delete one file"),_L("[drive:][path][filename]"),TShellCommand::ESSwitch,ShellFunction::Del),
 	TShellCommand(_L("DIR"),_L("Show directory contents"),_L("[drive:][path][filename] [/p][/w]\n\n  /p - Pause after each screen of information\n  /w - Wide format"),TShellCommand::EPSwitch|TShellCommand::EWSwitch|TShellCommand::EASwitch,ShellFunction::Dir),
+//	TShellCommand(_L("EDLIN"),_L("Edit a text file"),_L("[drive:][path][filename] [/p]\n\n  /p - Pause after each screen of information"),TShellCommand::EPSwitch,ShellFunction::Edit),
     TShellCommand(_L("FORMAT"),_L("Format a disk"),ptrFormatHelp,TShellCommand::EQSwitch|TShellCommand::ESSwitch|TShellCommand::EESwitch|TShellCommand::EFSwitch,ShellFunction::Format),
     TShellCommand(_L("GOBBLE"),_L("Create a file"),_L("[filename] size [/e]\n\n /e - create an empty file, without writing any data"),TShellCommand::EESwitch,ShellFunction::Gobble),
 	TShellCommand(_L("HEXDUMP"),_L("Display the contents of a file in hexadecimal"),_L("[drive:][path][filename] [/p]\n\n  /p - Pause after each screen of information\n\n  Hit escape to exit from hexdump "),TShellCommand::EPSwitch,ShellFunction::Hexdump),
@@ -496,15 +498,13 @@
 	TInt r=CShell::TheFs.CharToDrive(CShell::currentPath[0], drive);
 	if (r!=KErrNone)
 		return(r);
-	
 	if (aPath.Length()==0)
 		{
 		r=CShell::TheFs.Volume(vol, drive);
 		if (r==KErrNone)
-			CShell::Printf(_L("Volume Label:%S\n"),&vol.iName);
+			CShell::TheConsole->Printf(_L("Volume = %S\n"),&vol.iName);
 		return(r);
 		}
-	
 	r=CShell::TheFs.SetVolumeLabel(aPath, drive);
 	return(r);
 	}
@@ -582,39 +582,21 @@
 
 }
 
-/**
-    outputs content of the buffer to console according to settings passed in aSwitches
-    @return ETrue if the user pressed Esc key 
-*/
-TBool ShellFunction::OutputContentsToConsole(RPointerArray<HBufC>& aText,TUint aSwitches)
+
+void ShellFunction::OutputContentsToConsole(RPointerArray<HBufC>& aText,TUint aSwitches)
+//outputs content of the buffer to console according to settings passed in aSwitches
 	{
 	if ((aText.Count()>0)&&((aSwitches&TShellCommand::EWSwitch)!=0))
 		AlignTextIntoColumns(aText);
 
-	TKeyCode key=EKeyNull;
-    TInt i;
-
-    for(i=0;i<aText.Count();i++)
-		{                                             
-		key = CShell::WriteBufToConsole(((aSwitches&TShellCommand::EPSwitch)!=0),*aText[i]);
-		if(key == EKeyEscape)
-            break;
-        
-        key = CShell::WriteBufToConsole(EFalse,_L("\n"));
-		if(key == EKeyEscape)
-            break;
-
-		}
-    
-    //-- clean up string array
-    for(i=0; i<aText.Count(); i++)
-        {
+	for (TInt i=0;i<aText.Count();i++)
+		{
+		CShell::OutputStringToConsole(((aSwitches&TShellCommand::EPSwitch)!=0),*aText[i]);
+		CShell::OutputStringToConsole(EFalse,_L("\n"));
 		delete aText[i];
 		}
-	
+	//empty string array
 	aText.Reset();
-
-    return (key == EKeyEscape);
 	}
 
 
@@ -624,7 +606,6 @@
 	TInt count=aDirList->Count();
 	TInt fileCount=0, dirCount=0, printCount=0;
 	TInt64 byteCount=0;
-    TBool bBreak=EFalse;
 
 	//compose an array of strings describing entries in the directory
 	for (TInt j=0;j<count;j++)
@@ -660,76 +641,42 @@
 			TPtr name=buf->Des();
 			name=entry.iName;
 
-            const TPtrC desName(entry.iName);
-            const TBool bNameCut = desName.Length() > 26;
-
-            _LIT(KDots, ">.."); //-- will be displayed if the name is longer than 26 characters
-            _LIT(KSpc,  "   ");
-			
-            
 			if (entry.IsDir())
 				{
 				dirCount++;
-				
-                name.Format(_L(" %- 26S%S<DIR>         %+02d/%+02d/%- 4d  %02d:%02d:%02d.%03d"),
-				    &desName,
-                    bNameCut ? &KDots : &KSpc,
-                    modTime.Day()+1,modTime.Month()+1,modTime.Year(),modTime.Hour(),modTime.Minute(),modTime.Second(),modTime.MicroSecond());
-				
-                //name.Format(_L(" %- 26S   <DIR>         %+02d/%+02d/%- 4d  %02d:%02d:%02d.%06d"),
-				//							&entry.iName,modTime.Day()+1,modTime.Month()+1,modTime.Year(),modTime.Hour(),modTime.Minute(),modTime.Second(),modTime.MicroSecond());
+				name.Format(_L(" %- 26S   <DIR>         %+02d/%+02d/%- 4d  %02d:%02d:%02d.%06d"),
+											&entry.iName,modTime.Day()+1,modTime.Month()+1,modTime.Year(),modTime.Hour(),modTime.Minute(),modTime.Second(),modTime.MicroSecond());
 				}
 			else
 				{
 				TInt64 entrySize = entry.FileSize();
 				byteCount+=entrySize;
 				fileCount++;
-
-                name.Format(_L(" %- 26S%S%-11Lu   %+02d/%+02d/%- 4d  %02d:%02d:%02d.%03d"),
- 				    &desName,
-                    bNameCut ? &KDots : &KSpc,
-                    entrySize,
-                    modTime.Day()+1,modTime.Month()+1,modTime.Year(),modTime.Hour(),modTime.Minute(),modTime.Second(),modTime.MicroSecond());
- 				
-                //name.Format(_L(" %- 32S%+ 15Lu   %+02d/%+02d/%- 4d  %02d:%02d:%02d.%06d"),
- 				//							&entry.iName,entrySize,modTime.Day()+1,modTime.Month()+1,modTime.Year(),modTime.Hour(),modTime.Minute(),modTime.Second(),modTime.MicroSecond());
+ 				name.Format(_L(" %- 32S%+ 15Lu   %+02d/%+02d/%- 4d  %02d:%02d:%02d.%06d"),
+ 											&entry.iName,entrySize,modTime.Day()+1,modTime.Month()+1,modTime.Year(),modTime.Hour(),modTime.Minute(),modTime.Second(),modTime.MicroSecond());
 				}
 			}
 		User::LeaveIfError(aText.Append(buf ));
 		printCount++;
-		
 		//print the contents if a screen size of data is available. This will prevent huge buffer allocation.
 		if(printCount == CShell::TheConsole->ScreenSize().iHeight)
 			{
-			bBreak = OutputContentsToConsole(aText,aSwitches);
+			OutputContentsToConsole(aText,aSwitches);
 			printCount=0;
 			}
-		
 		CleanupStack::Pop();
 
-        if(bBreak)
-            break;    
 		}
-	
-    if(bBreak)
-        return; //-- the user has interrupted the listing
-
-    
 	OutputContentsToConsole(aText,aSwitches);
 
-	//---------------------------------
-    //-- print out summary information
-	TBuf<100> buf;
-    buf.Format(_L("    %d File%c"), fileCount, (fileCount==1) ? ' ':'s');
-    if(fileCount > 0)
+	//output summary information
+	CShell::OutputStringToConsole(((aSwitches&TShellCommand::EPSwitch)!=0),_L("    %d File%c\n"),fileCount,(fileCount==1)?' ':'s');
+	if (fileCount!=0)
 		{
-        buf.AppendFormat(_L(", %LU bytes"), byteCount);
+		CShell::OutputStringToConsole(((aSwitches&TShellCommand::EPSwitch)!=0),_L("  %lu byte%c\n"),byteCount,(fileCount==1)?' ':'s');
 		}
 
-    buf.Append(KNl);
-    
-    CShell::OutputStringToConsole(((aSwitches&TShellCommand::EPSwitch)!=0), buf);
-    
+	TBuf<50> buf;// allocate string long enough for additional information(number of directories)
 	buf.Format(_L("    %d Director"),dirCount);
 	if (dirCount==1)
 		buf.AppendFormat(_L("y\n"));
@@ -737,8 +684,6 @@
 		buf.AppendFormat(_L("ies\n"));
 
 	CShell::OutputStringToConsole(((aSwitches&TShellCommand::EPSwitch)!=0),buf);
-
-    
 	}
 
 TInt ShellFunction::Dir(TDes& aPath,TUint aSwitches)
@@ -764,7 +709,7 @@
 	TInt r=dir.Open(TheShell->TheFs,aPath,KEntryAttMaskSupported);
 	if (r!=KErrNone)
 		{
-		CShell::Printf(_L("File or directory not found\n"));
+		CShell::TheConsole->Printf(_L("File or directory not found\n"));
 		return(KErrNone);
 		}
 
@@ -779,7 +724,7 @@
 
 	//Sets the new length of path to the position of the last path delimiter +1
 	aPath.SetLength(aPath.LocateReverse(KPathDelimiter)+1);
-	CShell::Printf(_L("Directory of %S\n"),&aPath);
+	CShell::TheConsole->Printf(_L("Directory of %S\n"),&aPath);
 
 	//allocate array to be used as an output buffer
 	RPointerArray<HBufC>* text=new(ELeave) RPointerArray<HBufC>();
@@ -797,6 +742,13 @@
 	};
 
 
+TInt ShellFunction::Edit(TDes& /*aPath*/,TUint /*aSwitches*/)
+//
+//	Dummy, used by edlin (now retired)
+//
+	{
+	return(KErrNone);
+	}
 
 
 TInt ShellFunction::Attrib(TDes& aPath,TUint aSwitches)
@@ -1055,14 +1007,14 @@
         if(aDrvInfo.iDriveAtt & KDriveAttRedirected)    aPrintBuf.Append(_L("KDriveAttRedirected,"));
         if(aDrvInfo.iDriveAtt & KDriveAttSubsted)       aPrintBuf.Append(_L("KDriveAttSubsted,"));
         if(aDrvInfo.iDriveAtt & KDriveAttInternal)      aPrintBuf.Append(_L("KDriveAttInternal,"));
-        if(aDrvInfo.iDriveAtt & KDriveAttRemovable)     aPrintBuf.Append(_L("KDriveAttRemovable,"));
-
-        if(aDrvInfo.iDriveAtt & KDriveAttRemote)        aPrintBuf.Append(_L("KDriveAttRemote,"));
-        if(aDrvInfo.iDriveAtt & KDriveAttTransaction)   aPrintBuf.Append(_L("KDriveAttTransaction,"));
-
-        if(aDrvInfo.iDriveAtt & KDriveAttPageable)              aPrintBuf.Append(_L("KDriveAttPageable,"));
-        if(aDrvInfo.iDriveAtt & KDriveAttLogicallyRemovable)    aPrintBuf.Append(_L("KDriveAttLogicallyRemovable,"));
-        if(aDrvInfo.iDriveAtt & KDriveAttHidden)                aPrintBuf.Append(_L("KDriveAttHidden,"));
+        if(aDrvInfo.iDriveAtt & KDriveAttRemovable)     aPrintBuf.Append(_L("KDriveAttRemovable"));
+
+        if(aDrvInfo.iDriveAtt & KDriveAttRemote)        aPrintBuf.Append(_L("KDriveAttRemote"));
+        if(aDrvInfo.iDriveAtt & KDriveAttTransaction)   aPrintBuf.Append(_L("KDriveAttTransaction"));
+
+        if(aDrvInfo.iDriveAtt & KDriveAttPageable)              aPrintBuf.Append(_L("KDriveAttPageable"));
+        if(aDrvInfo.iDriveAtt & KDriveAttLogicallyRemovable)    aPrintBuf.Append(_L("KDriveAttLogicallyRemovable"));
+        if(aDrvInfo.iDriveAtt & KDriveAttHidden)                aPrintBuf.Append(_L("KDriveAttHidden"));
 
         aPrintBuf.Append(_L("\n"));
     }
@@ -1084,12 +1036,12 @@
         if(aDrvInfo.iMediaAtt & KMediaAttFormattable)       aPrintBuf.Append(_L("KMediaAttFormattable,"));
         if(aDrvInfo.iMediaAtt & KMediaAttWriteProtected)    aPrintBuf.Append(_L("KMediaAttWriteProtected,"));
         if(aDrvInfo.iMediaAtt & KMediaAttLockable)          aPrintBuf.Append(_L("KMediaAttLockable,"));
-        if(aDrvInfo.iMediaAtt & KMediaAttLocked)            aPrintBuf.Append(_L("KMediaAttLocked,"));
-
-        if(aDrvInfo.iMediaAtt & KMediaAttHasPassword)       aPrintBuf.Append(_L("KMediaAttHasPassword,"));
-        if(aDrvInfo.iMediaAtt & KMediaAttReadWhileWrite)    aPrintBuf.Append(_L("KMediaAttReadWhileWrite,"));
-        if(aDrvInfo.iMediaAtt & KMediaAttDeleteNotify)      aPrintBuf.Append(_L("KMediaAttDeleteNotify,"));
-        if(aDrvInfo.iMediaAtt & KMediaAttPageable)          aPrintBuf.Append(_L("KMediaAttPageable,"));
+        if(aDrvInfo.iMediaAtt & KMediaAttLocked)            aPrintBuf.Append(_L("KMediaAttLocked"));
+
+        if(aDrvInfo.iMediaAtt & KMediaAttHasPassword)       aPrintBuf.Append(_L("KMediaAttHasPassword"));
+        if(aDrvInfo.iMediaAtt & KMediaAttReadWhileWrite)    aPrintBuf.Append(_L("KMediaAttReadWhileWrite"));
+        if(aDrvInfo.iMediaAtt & KMediaAttDeleteNotify)      aPrintBuf.Append(_L("KMediaAttDeleteNotify"));
+        if(aDrvInfo.iMediaAtt & KMediaAttPageable)          aPrintBuf.Append(_L("KMediaAttPageable"));
         
 
         aPrintBuf.Append(_L("\n"));
@@ -1211,8 +1163,8 @@
 
             CShell::Printf(_L("Mounted FS:%S\n"), &Buf);
 
-            //-- print out the list of supported file systems if there are more than 0
-            nRes = aFs.SupportedFileSystemName(fsName, aDrvNum, 0); //-- try to get 1st child name
+            //-- print out the list of supported file systems if there are more than 1
+            nRes = aFs.SupportedFileSystemName(fsName, aDrvNum, 0+1); //-- try to get 2nd child name
             if(nRes == KErrNone)
             {
                 Buf.Copy(_L("Supported FS: "));
@@ -1484,16 +1436,16 @@
     {//-- gaceful attempt to dismount the FS
     nRes = aFs.DismountFileSystem(fsName, aDrvNum);
     if(nRes != KErrNone)
-    {
+        {
         CShell::TheConsole->Printf(_L("Can't dismount FS!\n"));
         return nRes;
-    }
+        }
     else
-    {
-    CShell::TheConsole->Printf(_L("'%S' filesystem dismounted from drive %c:\n"), &fsName, 'A'+aDrvNum);
-    return KErrNone;
+        {
+        CShell::TheConsole->Printf(_L("'%S' filesystem dismounted from drive %c:\n"), &fsName, 'A'+aDrvNum);
+        return KErrNone;
+        }
     }
-}
     else
     {//-- dismount by force
         TRequestStatus rqStat;
@@ -2054,60 +2006,52 @@
     }
 
 //-----------------------------------------------------------------------------------------------------------------------
-/**
-    Hex Dump of a file
-*/
+
 TInt ShellFunction::Hexdump(TDes& aPath,TUint aSwitches)
 	{
 	ShellFunction::StripQuotes(aPath);
 
 	ParsePath(aPath);
-	
 	RFile64 file;
 	TInt r=file.Open(TheShell->TheFs,aPath,EFileStream);
 	if (r!=KErrNone)
 		return(r);
 
-		const TInt KLineLength = 16;
-    TBuf<0x100> buf;
-    TBuf<KLineLength> asciiBuf;
-		TBuf8<KLineLength> line;
-
+	TInt offset=0;
 	for (;;)
 		{
+		const TInt KLineLength = 16;
+
+		TBuf8<KLineLength> line;
 		r=file.Read(line);
 		if (r != KErrNone || line.Length() == 0)
 			break;
 
-		buf.Zero();
-        asciiBuf.Zero();
-		
+		TBuf<KLineLength*3+2> hexaRep;
+		TBuf<KLineLength> asciiRep;
 		for (TInt i=0; i<KLineLength; i++)
 			{
 			if (i == KLineLength/2)
 				{
-				buf.Append(' ');
-				buf.Append(i<line.Length() ? '|' : ' ');
+				hexaRep.Append(' ');
+				hexaRep.Append(i<line.Length() ? '|' : ' ');
 				}
 
-            buf.Append(' ');
+			hexaRep.Append(' ');
 
 			if (i<line.Length())
 				{
-				buf.AppendNumFixedWidth(line[i], EHex, 2);
-				asciiBuf.Append(TChar(line[i]).IsPrint() ? line[i] : '.');
+				hexaRep.AppendNumFixedWidth(line[i], EHex, 2);
+				asciiRep.Append(TChar(line[i]).IsPrint() ? line[i] : '.');
 				}
 			else
-				buf.AppendFill(' ', 2);
+				hexaRep.AppendFill(' ', 2);
 			}
 
 		_LIT(KPrompt , " Hit escape to quit hexdump or any other key to continue\n");
-		
-        buf.Append(_L(" "));
-        buf.Append(asciiBuf);
-        buf.Append(KNl);
-
-        TKeyCode key= CShell::WriteBufToConsole((aSwitches&TShellCommand::EPSwitch)!=0, buf, KPrompt);
+		_LIT(KLineFmt, " %+07x0:%S %S\n");
+		TKeyCode key=CShell::OutputStringToConsole(KPrompt ,(aSwitches&TShellCommand::EPSwitch)!=0,KLineFmt, offset++,&hexaRep, &asciiRep);
+
 		if (key==EKeyEscape)
 				break;
 		}
@@ -2211,7 +2155,7 @@
 
 
     if(!(aSwitches&TShellCommand::EESwitch))
-    {//-- fill created file with random data
+    {//-- fill created file with randomn data
 
 	    while(rem)
 	    {
@@ -2434,22 +2378,22 @@
 	TInt DisplayHelp();
 	TInt DisplayMessage(const TFullName& aName);
 	TInt DisplayCmdUnknown();
-	void GetAll(const TDes& aName);
-	void GetProcesses(const TDes& aName);
-	void GetThreads(const TDes& aName);
-	void GetChunks(const TDes& aName);
-	void GetServers(const TDes& aName);
+	TInt GetAll(const TDes& aName);
+	TInt GetProcesses(const TDes& aName);
+	TInt GetThreads(const TDes& aName);
+	TInt GetChunks(const TDes& aName);
+	TInt GetServers(const TDes& aName);
 //	TInt GetSessions(const TDes& aName);
-	void GetLibraries(const TDes& aName);
+	TInt GetLibraries(const TDes& aName);
 //	TInt GetLogicalChannels(const TDes& aName);
-	void GetLogicalDevices(const TDes& aName);
-	void GetPhysicalDevices(const TDes& aName);
-	void GetSemaphores(const TDes& aName);
-	void GetMutexes(const TDes& aName);
+	TInt GetLogicalDevices(const TDes& aName);
+	TInt GetPhysicalDevices(const TDes& aName);
+	TInt GetSemaphores(const TDes& aName);
+	TInt GetMutexes(const TDes& aName);
 private:
 	void DisplayHelpLine(const TDesC& aCommand, const TDesC& aDescription);
-	TBool Prepare(const TFullName& aName);
-	TBool Prepare(const TFullName& aName,TCallBack& aCallBack);
+	TInt Prepare(const TFullName& aName);
+	TInt Prepare(const TFullName& aName,TCallBack& aCallBack);
 	TInt Display(TFullName& aName);
 	TFullName iPrevName;
 	TCallBack iCallBack;
@@ -2491,8 +2435,9 @@
 	return KErrNone;
 	}
 
-void TShowProcInfo::GetAll(const TDes& aName)
+TInt TShowProcInfo::GetAll(const TDes& aName)
 	{
+
 	GetProcesses(aName);
 	GetThreads(aName);
 	GetChunks(aName);
@@ -2504,27 +2449,24 @@
 	GetPhysicalDevices(aName);
 	GetSemaphores(aName);
 	GetMutexes(aName);
-
+	return KErrNone;
 	}
 
-void TShowProcInfo::GetProcesses(const TDes& aName)
+TInt TShowProcInfo::GetProcesses(const TDes& aName)
 	{
 
 	TFindProcess findHb;
 	findHb.Find(aName);
 	TFullName name;
-	
-    if(!Prepare(_L("PROCESSES")))
-       return;
-
+	Prepare(_L("PROCESSES"));
 	while (findHb.Next(name)==KErrNone)
 		{
 		Display(name);
 		}
-
+	return KErrNone;
 	}
 
-void TShowProcInfo::GetThreads(const TDes& aName)
+TInt TShowProcInfo::GetThreads(const TDes& aName)
 	{
 	TInt threads=0;
 	TFindThread findHb;
@@ -2534,10 +2476,7 @@
 
 //	Modified by WR, November 1997
 	TCallBack threadCallBack(GetThreadInfo,findPtr);
-	
-    if(!Prepare(_L("THREADS"),threadCallBack))
-        return;
-
+	Prepare(_L("THREADS"),threadCallBack);
 	while (findHb.Next(name)==KErrNone)
 		{
 		Display(name);
@@ -2549,12 +2488,12 @@
 		message.Format(_L("? No threads called %S"), &aName);
 		DisplayMessage(message);
 		}
-	
-    
+	return KErrNone;
+//	End of modification
 	}
 
 
-void TShowProcInfo::GetChunks(const TDes& aName)
+TInt TShowProcInfo::GetChunks(const TDes& aName)
 	{
 
 	TFindChunk findHb;
@@ -2562,10 +2501,7 @@
 	TFullName name;
 	TAny* namePtr=(TAny*)&name;
 	TCallBack chunkCallBack(GetChunkInfo,namePtr);
-	
-    if(!Prepare(_L("CHUNKS & SIZES"),chunkCallBack))
-        return;
-
+	Prepare(_L("CHUNKS & SIZES"),chunkCallBack);
 	TInt totalChunkSize=0;
 	TInt protectedChunks = 0;
 	while (findHb.Next(name)==KErrNone)
@@ -2592,23 +2528,21 @@
 	CShell::OutputStringToConsole(ETrue,_L("  Total Chunk Size = %dk\n"),totalChunkSize);
 	if(protectedChunks)
 		CShell::OutputStringToConsole(ETrue,_L("  %d Protected chunks not counted\n"),protectedChunks);
-	
-    
+	return KErrNone;
 	}
 
-void TShowProcInfo::GetServers(const TDes& aName)
+TInt TShowProcInfo::GetServers(const TDes& aName)
 	{
 
 	TFindServer findHb;
 	findHb.Find(aName);
 	TFullName name;
-	if(!Prepare(_L("SERVERS")))
-        return;
-
+	Prepare(_L("SERVERS"));
 	while (findHb.Next(name)==KErrNone)
 		{
 		Display(name);
 		}
+	return KErrNone;
 	}
 
 /*	TInt TShowProcInfo::GetSessions(const TDes& aName)
@@ -2625,20 +2559,18 @@
 	return KErrNone;
 	}
 */
-void TShowProcInfo::GetLibraries(const TDes& aName)
+TInt TShowProcInfo::GetLibraries(const TDes& aName)
 	{
 
 	TFindLibrary findHb;
 	findHb.Find(aName);
 	TFullName name;
-	if(!Prepare(_L("LIBRARIES")))
-        return;
-
+	Prepare(_L("LIBRARIES"));
 	while (findHb.Next(name)==KErrNone)
 		{
 		Display(name);
 		}
-	
+	return KErrNone;
 	}
 /*
 TInt TShowProcInfo::GetLogicalChannels(const TDes& aName)
@@ -2656,68 +2588,59 @@
 	}
 */
 
-void TShowProcInfo::GetLogicalDevices(const TDes& aName)
+TInt TShowProcInfo::GetLogicalDevices(const TDes& aName)
 	{
 
 	TFindLogicalDevice findHb;
 	findHb.Find(aName);
 	TFullName name;
-
-	if(!Prepare(_L("LOGICAL DEVICES")))
-        return;
-
+	Prepare(_L("LOGICAL DEVICES"));
 	while (findHb.Next(name)==KErrNone)
 		{
 		Display(name);
 		}
-	
+	return KErrNone;
 	}
 
-void TShowProcInfo::GetPhysicalDevices(const TDes& aName)
+TInt TShowProcInfo::GetPhysicalDevices(const TDes& aName)
 	{
 
 	TFindPhysicalDevice findHb;
 	findHb.Find(aName);
 	TFullName name;
-	
-    if(!Prepare(_L("PHYSICAL DEVICES")))
-        return;
-
+	Prepare(_L("PHYSICAL DEVICES"));
 	while (findHb.Next(name)==KErrNone)
 		{
 		Display(name);
 		}
-	
+	return KErrNone;
 	}
 
-void TShowProcInfo::GetSemaphores(const TDes& aName)
+TInt TShowProcInfo::GetSemaphores(const TDes& aName)
 	{
 	TFindSemaphore findHb;
 	findHb.Find(aName);
 	TFullName name;
-	if(!Prepare(_L("SEMAPHORES")))
-        return;
-
+	Prepare(_L("SEMAPHORES"));
 	while (findHb.Next(name)==KErrNone)
 		{
 		Display(name);
 		}
-	
+	return KErrNone;
 	}
 
-void TShowProcInfo::GetMutexes(const TDes& aName)
+TInt TShowProcInfo::GetMutexes(const TDes& aName)
 	{
 
 	TFindMutex findHb;
 	findHb.Find(aName);
 	TFullName name;
-	if(!Prepare(_L("MUTEXES")))
-        return;
+	Prepare(_L("MUTEXES"));
 	while (findHb.Next(name)==KErrNone)
 		{
 		Display(name);
 		}
-	
+	return KErrNone;
 	}
 
 void TShowProcInfo::DisplayHelpLine(const TDesC& aCommand, const TDesC& aDescription)
@@ -2726,32 +2649,23 @@
 	}
 
 
-TBool TShowProcInfo::Prepare(const TFullName& aName)
+TInt TShowProcInfo::Prepare(const TFullName& aName)
 	{
 
 	iPrevName=_L("");
-	TKeyCode key = CShell::OutputStringToConsole(ETrue,_L("--%S-->\n"),&aName);
-    
-    if(key==EKeyEscape)
-        return EFalse;
-
+	CShell::OutputStringToConsole(ETrue,_L("--%S-->\n"),&aName);
 	useCallBack=EFalse;
-    return ETrue;
+	return KErrNone;
 	}
 
-TBool  TShowProcInfo::Prepare(const TFullName& aName,TCallBack& aCallBack)
+TInt TShowProcInfo::Prepare(const TFullName& aName,TCallBack& aCallBack)
 	{
+
 	iPrevName=_L("");
-	TKeyCode key = CShell::OutputStringToConsole(ETrue,_L("--%S-->\n"),&aName);
-
-    if(key==EKeyEscape)
-        return EFalse;
-	
-    
+	CShell::OutputStringToConsole(ETrue,_L("--%S-->\n"),&aName);
 	useCallBack=ETrue;
 	iCallBack=aCallBack;
-	
-    return ETrue;
+	return KErrNone;
 	}
 
 TInt TShowProcInfo::Display(TFullName& aName)
@@ -2784,11 +2698,7 @@
 		while (posA>=0)
 			{
 			TPtrC16 temp_desc=aName.Left(posA);
-			
-            TKeyCode key = CShell::OutputStringToConsole(ETrue,_L("%+ *S\n"),toTab+temp_desc.Left(posA).Length(),&temp_desc);
-			if (key==EKeyEscape)
-			    break;
-
+			CShell::OutputStringToConsole(ETrue,_L("%+ *S\n"),toTab+temp_desc.Left(posA).Length(),&temp_desc);
 			toTab+=3;
 			aName.Delete(0,posA+2);
 			posA=aName.Match(_L("*::*"));
@@ -2819,7 +2729,7 @@
 	TBool abort=EFalse;
 	TBool processSelected=EFalse;
 	TBuf<0x16> prompt=_L("ps>");
-	showProcInfo.GetProcesses(processPrefix);
+	r=showProcInfo.GetProcesses(processPrefix);
 	do
 		{
 		TBuf<0x10> command;
@@ -2881,7 +2791,7 @@
 						if (findP.Next(findName)==KErrNone)
 							{
 							r=showProcInfo.DisplayMessage(_L("command prefixes more than one process"));
-							showProcInfo.GetProcesses(chosenP);
+							r=showProcInfo.GetProcesses(chosenP);
 							}
 						else
 							{
@@ -2895,42 +2805,42 @@
 					break;
 				case 'A':
 					{
-					showProcInfo.GetAll(processPrefix);
+					r=showProcInfo.GetAll(processPrefix);
 					command.Zero();
 					}
 					break;
 				case 'P':
-					showProcInfo.GetProcesses(asterisk);
+					r=showProcInfo.GetProcesses(asterisk);
 					break;
 				case 'T':
-					showProcInfo.GetThreads(processPrefix);
+					r=showProcInfo.GetThreads(processPrefix);
 					break;
 				case 'C':
-					showProcInfo.GetChunks(processPrefix);
+					r=showProcInfo.GetChunks(processPrefix);
 					break;
 				case 'S':
-					showProcInfo.GetServers(processPrefix);
+					r=showProcInfo.GetServers(processPrefix);
 					break;
 /*				case 'I':
 					r=showProcInfo.GetSessions(processPrefix);
 					break;
 */				case 'L':
-					showProcInfo.GetLibraries(processPrefix);
+					r=showProcInfo.GetLibraries(processPrefix);
 					break;
 //				case 'G':
 //					r=showProcInfo.GetLogicalChannels(processPrefix);
 //					break;
 				case 'V':
-					showProcInfo.GetLogicalDevices(processPrefix);
+					r=showProcInfo.GetLogicalDevices(processPrefix);
 					break;
 				case 'D':
-					showProcInfo.GetPhysicalDevices(processPrefix);
+					r=showProcInfo.GetPhysicalDevices(processPrefix);
 					break;
 				case 'E':
-					showProcInfo.GetSemaphores(processPrefix);
+					r=showProcInfo.GetSemaphores(processPrefix);
 					break;
 				case 'M':
-					showProcInfo.GetMutexes(processPrefix);
+					r=showProcInfo.GetMutexes(processPrefix);
 					break;
 				default:
 					{
@@ -3234,6 +3144,7 @@
 		c=*p, *p=p[1], p[1]=c;
 	}
 
+_LIT(KLitPercentS, "%S");
 TInt ShellFunction::Type(TDes& aPath,TUint aSwitches)
 	{
 	ParsePath(aPath);
@@ -3295,7 +3206,7 @@
 			{
 			nchars=0;
 			TPtrC bufLeft=buf.Left(r+1);
-            key = CShell::WriteBufToConsole((aSwitches&TShellCommand::EPSwitch)!=0, bufLeft);
+			key = CShell::OutputStringToConsole((aSwitches&TShellCommand::EPSwitch)!=0,KLitPercentS(), &bufLeft);
 			buf.Set(buf.Mid(r+1));
 	
     		if(key == EKeyEscape) 
@@ -3305,8 +3216,7 @@
 		nchars=buf.Length();
 		if (nchars)
 			{
-    		key = CShell::WriteBufToConsole((aSwitches&TShellCommand::EPSwitch)!=0, buf);
-
+            key = CShell::OutputStringToConsole((aSwitches&TShellCommand::EPSwitch)!=0,KLitPercentS(), &buf);
     		if(key == EKeyEscape) 
                 goto exit;
 
@@ -3725,35 +3635,9 @@
 
 
 //----------------------------------------------------------------------
-void CShell::Print(const TDesC16& aBuf)
-{
-
-    TheConsole->Write(aBuf);
-
-    if(iDbgPrint)
-    {
-        const TInt bufLen = aBuf.Length();
-        
-        if(bufLen >1 && aBuf[bufLen-1] == '\n' && aBuf[bufLen-2] != '\r')
-            {
-            RDebug::RawPrint(aBuf.Left(bufLen-1));            
-            RDebug::RawPrint(_L8("\r\n"));
-            }
-        else if(bufLen == 1 && aBuf[bufLen-1] == '\n')
-            {
-            RDebug::RawPrint(_L8("\r\n"));
-            }
-        else
-            {
-            RDebug::RawPrint(aBuf);
-            }
-    }
-
-}
-
 void CShell::Printf(TRefByValue<const TDesC16> aFmt, ...)
 {
-	TBuf<0x200> buf;
+	TBuf<256> buf;
 	VA_LIST list;					
 	VA_START(list, aFmt);
 	// coverity[uninit_use_in_call]
@@ -3762,12 +3646,24 @@
     if(!buf.Length())
         return;
 
-    Print(buf);
+    TheConsole->Printf(buf);
+
+    if(iDbgPrint)
+    {
+        const TInt bufLen = buf.Length();
+        if(buf[bufLen-1] == '\n')
+        {
+            buf.Insert(bufLen-1, _L("\r"));
+        }
+    
+        RDebug::RawPrint(buf);
+    }
+
 }
 
 void SIPrintf(TRefByValue<const TDesC16> aFmt, ...)
 	{
-	TBuf<0x200> buf;
+	TBuf<256> buf;
 	VA_LIST list;					
 	VA_START(list, aFmt);
 	// coverity[uninit_use_in_call]
@@ -3842,7 +3738,7 @@
 		aProg.Append(_L(".EXE"));
 
 #ifdef _DEBUG
-	CShell::Printf(_L("RUNEXEC: command %S, parameters %S, count %d, forever %d, issecs %d, exiterr %d"),
+	SIPrintf(_L("RUNEXEC: command %S, parameters %S, count %d, forever %d, issecs %d, exiterr %d"),
 		&aProg, &parameters, count, forever, countIsSecs, exitOnErr); 
 #endif
 	TInt i=0;
@@ -3857,7 +3753,7 @@
 		r = newProcess.Create(aProg, parameters);
 		if (r != KErrNone)
 			{
-			CShell::Printf(KRunExecFailedProcessCreate, &aProg, r);
+			SIPrintf(KRunExecFailedProcessCreate, &aProg, r);
 			return (r);						// this is systematic - must return
 			}
 		newProcess.Logon(status);
@@ -3871,7 +3767,7 @@
 		timeCurrent.HomeTime();
 		timeTaken = timeCurrent.MicroSecondsFrom(timeStart);
 		TInt msecs = I64LOW(timeTaken.Int64() / 1000);
-		CShell::Printf(KRunExecReportStatusAndTime, msecs, i+1, exitType, retcode, &exitCat);
+		SIPrintf(KRunExecReportStatusAndTime, msecs, i+1, exitType, retcode, &exitCat);
 
 		if (resetDebugRegs)
 			{