os/security/cryptomgmtlibs/securitytestfw/test/testhandler2/t_tefinput.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 //
     2 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 // All rights reserved.
     4 // This component and the accompanying materials are made available
     5 // under the terms of the License "Eclipse Public License v1.0"
     6 // which accompanies this distribution, and is available
     7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 //
     9 // Initial Contributors:
    10 // Nokia Corporation - initial contribution.
    11 //
    12 // Contributors:
    13 //
    14 // Description: 
    15 //
    16 
    17 
    18 #include <s32file.h>
    19 #include "t_tefinput.h"
    20 #include "t_errorconverter.h"
    21 #include "tScriptSetup.h"
    22 #include <securityerr.h>
    23 #include <keystore_errs.h>
    24 
    25 #ifdef SYMBIAN_AUTH_SERVER
    26 #include <auth_srv_errs.h>
    27 #endif
    28 
    29 _LIT8(KSpace, " ");
    30 _LIT8(KTab, "\t");
    31 _LIT8(KReturn, "\r");
    32 _LIT8(KNewline, "\n");
    33 _LIT8(KOpenBrk, "[");
    34 _LIT8(KCloseBrk, "]");
    35 _LIT8(KEquals, "=");
    36 _LIT8(KUnderScore, "_");
    37 _LIT8(KSectionIDTag, "[SEC");
    38 
    39 #define KIniSectionIdLength 512
    40 #define KResultLength 512
    41 
    42 // Extracts RUN_TESTSTEP from the whole of script file passed in
    43 
    44 EXPORT_C TPtrC8 Tefinput::ParseRunTestStep(const TDesC8& aBuf, 
    45 									const TDesC8& aTag,
    46 									TInt& aPos,
    47 									TInt& aError)
    48 	{
    49 	aError = KErrNone;
    50 	TInt endPos = 0;
    51 	TInt startPos = 0;
    52 	TInt tempPos = 0;
    53 
    54 	TPtrC8 data = aBuf.Mid(aPos);
    55 	
    56 	tempPos = data.Find(aTag);
    57 	
    58 	if (tempPos != KErrNotFound)
    59 		{
    60 		tempPos += aTag.Length();
    61 			
    62 		TPtrC8 temprunStepData = data.Mid(tempPos);		
    63 		
    64 		endPos = temprunStepData.Find(KNewline);
    65 		if (endPos == KErrNotFound)
    66 			{
    67 			endPos = temprunStepData.Find(KReturn);
    68 			}
    69 		if (endPos == KErrNotFound)
    70 			{
    71 			endPos = temprunStepData.Length();
    72 			}
    73 		
    74 		TInt len = 0;
    75 		len = (endPos - startPos) + 1;
    76 		TPtrC8 runStepData = temprunStepData.Mid(startPos,len);
    77 		aPos += tempPos + runStepData.Length();
    78 		return runStepData;
    79 		}
    80 	else
    81 		{
    82 		aError = KErrNotFound;
    83 		return TPtrC8();
    84 		}
    85 
    86 	// None found
    87 	
    88 
    89 	}
    90 
    91 // Extracts the nth word from the given descritor
    92 EXPORT_C TPtrC8 Tefinput::ParseNthElement(const TDesC8& aBuf, 
    93 									TInt aWordPos,
    94 									TInt& aError)
    95 
    96 	{
    97 	aError = KErrNone;
    98 	TInt startPos = KErrNotFound, endPos = KErrNotFound;
    99 	TInt wordCounter =0 ;
   100 	TBool inWord = EFalse;
   101 	TInt i =0;
   102 	for(i = 0; i < aBuf.Length() ; i ++)
   103 		{
   104 		TPtrC8 tmpChar = aBuf.Mid(i,1);
   105 		if(tmpChar == KSpace || tmpChar == KTab || tmpChar == KReturn || tmpChar == KNewline )
   106 			{
   107 			if(inWord)
   108 				{
   109 				if(wordCounter == aWordPos)
   110 					{
   111 					endPos =i-1;
   112 					break;
   113 					}
   114 				inWord = EFalse;
   115 				}			
   116 			}
   117 		else
   118 			{
   119 			if(inWord == EFalse)
   120 				{
   121 				wordCounter ++;
   122 				inWord = ETrue;
   123 				if(wordCounter == aWordPos)
   124 					{
   125 					startPos =i;
   126 					}
   127 				}
   128 			}
   129 		}	
   130 	
   131 	if(startPos < 0 || endPos < 0)
   132 		{
   133 		aError = KErrNotFound;
   134 		return TPtrC8();
   135 		}
   136 	else
   137 		{
   138 		return aBuf.Mid(startPos,(endPos-startPos+1));
   139 		}
   140 	}
   141 
   142 // Extracts testCaseID from the whole script file
   143 EXPORT_C TPtrC8 Tefinput::ParseTestCaseID(const TDesC8& aBuf,
   144 										  const TDesC8& aTag,
   145 										  TDes8& aPrevTestID,
   146 										  TInt& aPos, 
   147 										  TInt& aError,
   148 										  TBool& testSet,
   149 										  TBool& startTest
   150 										  )
   151 	{
   152 	aError = KErrNone;
   153 	TInt startPos = 0, endPos = 0;
   154 	
   155 	TPtrC8 datatemp;	
   156 	TPtrC8 testID;
   157 	TPtrC8 data = aBuf.Mid(aPos);
   158 	TInt len = aTag.Length();
   159 	startPos = data.Find(aTag);
   160 	
   161 	TInt filePos = startPos + aPos;
   162 	
   163 	if(startPos != KErrNotFound)
   164 		{
   165 		TInt templen;
   166 		startPos += len;
   167 		filePos += len;
   168 		datatemp.Set(data.Mid(startPos));
   169 		
   170 		endPos = datatemp.Find(KNewline);
   171 		if(endPos == KErrNotFound)
   172 			{
   173 			endPos = datatemp.Find(KReturn);
   174 			TInt temp =0;
   175 			templen = endPos - temp;
   176 			testID.Set(datatemp.Mid(temp,templen));
   177 			filePos += testID.Length();
   178 			aPos = filePos;
   179 			testSet = ETrue;
   180 			startTest = ETrue;
   181 			return Trim(testID);
   182 			}
   183 		else
   184 			{
   185 			TInt temp =0;
   186 			templen = endPos - temp;
   187 			testID.Set(datatemp.Mid(temp,templen));
   188 			filePos += testID.Length();
   189 			aPos = filePos;
   190 			testSet = ETrue;
   191 			startTest = ETrue;
   192 			return Trim(testID);
   193 			}		
   194 		}
   195 	else
   196 		{
   197 		aPos = aPos;
   198 		aError = KErrNotFound;
   199 		testSet = EFalse;
   200 		return aPrevTestID;
   201 		}
   202 
   203 	}
   204 
   205 
   206 // Generates the path for .ini file from the .script file path
   207 EXPORT_C TInt Tefinput::ParseiniPath(const TDesC8& aIniFileName, 
   208 									const TDesC& aScriptPath,
   209 									TDes& aIniFilePath)
   210 	{
   211 	
   212 	TInt err = KErrNone;	
   213 	TInt endPos = aScriptPath.LocateReverse('\\');
   214 	if (endPos == KErrNotFound)
   215 		{
   216 		err = KErrNotFound;
   217 		}
   218 	else
   219 		{
   220 		aIniFilePath.Copy(aIniFileName);
   221 		aIniFilePath.Insert(0, aScriptPath.Left(endPos+1));
   222 		}
   223 	return err;
   224 	}
   225 
   226 // Reads the whole of .ini file contents, calls ParseActionbody()
   227 //	to extract info between <actionbody></actionbody>tags
   228 EXPORT_C HBufC8* Tefinput::GetiniFile(RFs& aFs, 
   229 										const TDesC& aIniFilePath, 
   230 										TInt& err)
   231 	{
   232 	RFile iniFile;
   233 	err = iniFile.Open(aFs, aIniFilePath, EFileStream | EFileRead | EFileShareReadersOnly);
   234 	if (err != KErrNone)
   235 		{	
   236 		return NULL;	// Bad exit ...
   237 		}
   238 	// gets size of ini file
   239 	TInt size;
   240 	iniFile.Size(size);
   241 	iniFile.Close();
   242 			
   243 	// reads ini into iTestInput
   244 	HBufC8* testInput = HBufC8::NewLC(size);
   245 	
   246 	TPtr8	aInput = testInput->Des();   // Appoint our local 8 bit pointer descriptor to the heap area to work with
   247 	aInput.SetLength(size); 
   248 	
   249 	RFileReadStream stream;
   250 	User::LeaveIfError(stream.Open(aFs, aIniFilePath, EFileStream | EFileRead | EFileShareReadersOnly));
   251 	CleanupClosePushL(stream);
   252 	stream.ReadL(aInput, size);		// Load in the inifile into Heap buffer
   253 		
   254 //	TPtrC8 iniFileread = ParseElement(pInput, tempsectID, pos, err );
   255 //	TPtrC8 iniFileread = ParseActionbody(pInput, aIniSectionName, err);	
   256 //	iniFileread.TDesC8();
   257 	
   258 	CleanupStack::PopAndDestroy(1); // stream, 
   259 	
   260 	return testInput;  // Return a valid HBuf8 pointer where the ini file has been loaded (on the heap)
   261 	}
   262 
   263 // Extracts info between <actionbody></actionbody>tags from the inifile contents
   264 EXPORT_C TInt Tefinput::ParseActionbody( TPtrC8& aBuf, 
   265 											const TDesC8& aIniTag, 
   266 											TPtrC8& aSectionBody)
   267 	{
   268 	TInt len =0, startPos =0, endPos = 0;
   269 	TPtrC8 inifile = aBuf.Mid(startPos);
   270 	
   271 	TBuf8<KIniSectionIdLength> tempsectID(KOpenBrk);
   272 	tempsectID.Append(aIniTag);
   273 	tempsectID.Append(KCloseBrk);
   274 	
   275 	startPos = inifile.Find(tempsectID);
   276 	
   277 	if (startPos != KErrNotFound)
   278 		{
   279 		TPtrC8 actionblk = inifile.Mid(startPos + tempsectID.Length());		
   280 		endPos = actionblk.Find(KSectionIDTag);
   281 		if (endPos == KErrNotFound)
   282 			{
   283 			endPos = actionblk.Length();
   284 			}		
   285 		len = endPos - 0;
   286 		
   287 		aSectionBody.Set(aBuf.Mid(startPos + tempsectID.Length(),len));
   288 		return KErrNone;
   289 		}
   290 	else
   291 		{
   292 //		aSectionBody();
   293 		return KErrNotFound;
   294 		}
   295 	}
   296 
   297 // Takes in an integer and returns the appropriate error code with <return></return> tags
   298 EXPORT_C TInt Tefinput::GetActionResult(TInt aErrCode, TDes8& aReturnTag)
   299 	{
   300 	TInt err = KErrNone;
   301 	
   302 	if(aErrCode == KErrNone)
   303 		{
   304 		aReturnTag.Copy(_L8("\r\n\t\t<return>KErrNone</return>"));
   305 		}	
   306 	else if(aErrCode == KErrNotFound)
   307 		{
   308 		aReturnTag.Copy(_L8("\r\n\t\t<return>KErrNotFound</return>"));
   309 		}
   310 	else if(aErrCode == KErrGeneral)
   311 			{
   312 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrGeneral</return>"));
   313 			}	 
   314 	else if(aErrCode == KErrCancel)
   315 			{
   316 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrCancel</return>"));
   317 			}	
   318 	else if(aErrCode == KErrNoMemory)
   319 			{
   320 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrNoMemory</return>"));
   321 			}	
   322 
   323 	else if(aErrCode == KErrNotSupported)
   324 			{
   325 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrNotSupported</return>"));
   326 			}	
   327 
   328 	else if(aErrCode == KErrArgument)
   329 			{
   330 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrArgument</return>"));
   331 			}	
   332 
   333 	else if(aErrCode == KErrTotalLossOfPrecision)
   334 			{
   335 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrTotalLossOfPrecision</return>"));
   336 			}	
   337 
   338 	else if(aErrCode == KErrBadHandle)
   339 			{
   340 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrBadHandle</return>"));
   341 			}	
   342 
   343 	else if(aErrCode == KErrOverflow)
   344 			{
   345 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrOverflow</return>"));
   346 			}	
   347 
   348 	else if(aErrCode == KErrUnderflow)
   349 			{
   350 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrUnderflow</return>"));
   351 			}	
   352 
   353 	else if(aErrCode == KErrAlreadyExists)
   354 			{
   355 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAlreadyExists</return>"));
   356 			}	
   357 
   358 	else if(aErrCode == KErrPathNotFound)
   359 			{
   360 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrPathNotFound</return>"));
   361 			}	
   362 
   363 	else if(aErrCode == KErrDied)
   364 			{
   365 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrDied</return>"));
   366 			}	
   367 
   368 	else if(aErrCode == KErrInUse)
   369 			{
   370 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrInUse</return>"));
   371 			}	
   372 
   373 	else if(aErrCode == KErrServerTerminated)
   374 			{
   375 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrServerTerminated</return>"));
   376 			}	
   377 
   378 	else if(aErrCode == KErrServerBusy)
   379 			{
   380 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrServerBusy</return>"));
   381 			}	
   382 
   383 	else if(aErrCode == KErrCompletion)
   384 			{
   385 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrCompletion</return>"));
   386 			}	
   387 
   388 	else if(aErrCode == KErrNotReady)
   389 			{
   390 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrNotReady</return>"));
   391 			}	
   392 
   393 	else if(aErrCode == KErrUnknown)
   394 			{
   395 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrUnknown</return>"));
   396 			}	
   397 
   398 	else if(aErrCode == KErrCorrupt)
   399 			{
   400 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrCorrupt</return>"));
   401 			}	
   402 
   403 	else if(aErrCode == KErrAccessDenied)
   404 			{
   405 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAccessDenied</return>"));
   406 			}	
   407 
   408 	else if(aErrCode == KErrLocked)
   409 			{
   410 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrLocked</return>"));
   411 			}	
   412 
   413 	else if(aErrCode == KErrWrite)
   414 			{
   415 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrWrite</return>"));
   416 			}	
   417 
   418 	else if(aErrCode == KErrDisMounted)
   419 			{
   420 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrDisMounted</return>"));
   421 			}	
   422 
   423 	else if(aErrCode == KErrEof)
   424 			{
   425 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrEof</return>"));
   426 			}	
   427 
   428 	else if(aErrCode == KErrDiskFull)
   429 			{
   430 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrDiskFull</return>"));
   431 			}	
   432 
   433 	else if(aErrCode == KErrBadDriver)
   434 			{
   435 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrBadDriver</return>"));
   436 			}	
   437 
   438 	else if(aErrCode == KErrBadName)
   439 			{
   440 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrBadName</return>"));
   441 			}	
   442 
   443 	else if(aErrCode == KErrCommsLineFail)
   444 			{
   445 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrCommsLineFail</return>"));
   446 			}	
   447 
   448 	else if(aErrCode == KErrCommsFrame)
   449 			{
   450 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrCommsFrame</return>"));
   451 			}	
   452 
   453 	else if(aErrCode == KErrCommsOverrun)
   454 			{
   455 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrCommsOverrun</return>"));
   456 			}	
   457 
   458 	else if(aErrCode == KErrCommsParity)
   459 			{
   460 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrCommsParity</return>"));
   461 			}	
   462 
   463 	else if(aErrCode == KErrTimedOut)
   464 			{
   465 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrTimedOut</return>"));
   466 			}	
   467 
   468 	else if(aErrCode == KErrCouldNotConnect)
   469 			{
   470 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrCouldNotConnect</return>"));
   471 			}	
   472 
   473 	else if(aErrCode == KErrCouldNotDisconnect)
   474 			{
   475 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrCouldNotDisconnect</return>"));
   476 			}	
   477 
   478 	else if(aErrCode == KErrDisconnected)
   479 			{
   480 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrDisconnected</return>"));
   481 			}	
   482 
   483 	else if(aErrCode == KErrBadLibraryEntryPoint)
   484 			{
   485 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrBadLibraryEntryPoint</return>"));
   486 			}	
   487 
   488 	else if(aErrCode == KErrBadDescriptor)
   489 			{
   490 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrBadDescriptor</return>"));
   491 			}	
   492 
   493 	else if(aErrCode == KErrAbort)
   494 			{
   495 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAbort</return>"));
   496 			}	
   497 
   498 	else if(aErrCode == KErrTooBig)
   499 			{
   500 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrTooBig</return>"));
   501 			}	
   502 
   503 	else if(aErrCode == KErrDivideByZero)
   504 			{
   505 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrDivideByZero</return>"));
   506 			}	
   507 
   508 	else if(aErrCode == KErrBadPower)
   509 			{
   510 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrBadPower</return>"));
   511 			}	
   512 
   513 	else if(aErrCode == KErrDirFull)
   514 			{
   515 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrDirFull</return>"));
   516 			}	
   517 
   518 	else if(aErrCode == KErrHardwareNotAvailable)
   519 			{
   520 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrHardwareNotAvailable</return>"));
   521 			}		
   522 	else if(aErrCode == KErrPermissionDenied)
   523 			{
   524 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrPermissionDenied</return>"));
   525 			}	
   526 	else if(aErrCode == KErrBadPassphrase)
   527 			{
   528 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrBadPassphrase</return>"));
   529 			}
   530 	else if(aErrCode == KErrNotSecure)
   531 			{
   532 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrNotSecure</return>"));
   533 			}
   534 	else if(aErrCode == KErrKeyNotWeakEnough)
   535 			{
   536 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrKeyNotWeakEnough</return>"));
   537 			}
   538 	else if(aErrCode == KErrInvalidPadding)
   539 			{
   540 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrInvalidPadding</return>"));
   541 			}
   542 	else if(aErrCode == KErrWeakKey)
   543 			{
   544 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrWeakKey</return>"));
   545 			}
   546 	else if(aErrCode == KErrNegativeExportNotSupported)
   547 			{
   548 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrNegativeExportNotSupported</return>"));
   549 			}
   550 	else if(aErrCode == KErrKeyAlgorithm)
   551 			{
   552 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrKeyAlgorithm</return>"));
   553 			}
   554 	else if(aErrCode == KErrKeyUsage)
   555 			{
   556 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrKeyUsage</return>"));
   557 			}
   558 	else if(aErrCode == KErrKeyValidity)
   559 			{
   560 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrKeyValidity</return>"));
   561 			}
   562 	else if(aErrCode == KErrKeySize)
   563 			{
   564 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrKeySize</return>"));
   565 			}
   566 	else if(aErrCode == KErrKeyAccess)
   567 			{
   568 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrKeyAccess</return>"));
   569 			}
   570 	else if(aErrCode == KErrPrivateKeyNotFound)
   571 			{
   572 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrPrivateKeyNotFound</return>"));
   573 			}
   574 	else if(aErrCode == KErrAuthenticationFailure)
   575 			{
   576 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAuthenticationFailure</return>"));
   577 			}
   578 
   579 #ifdef SYMBIAN_AUTH_SERVER
   580 	else if(aErrCode == KErrAuthServUnsupportedExprVersion)
   581 			{
   582 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAuthServUnsupportedExprVersion</return>"));
   583 			}
   584 	else if(aErrCode == KErrAuthServNoSuchPlugin)
   585 			{
   586 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAuthServNoSuchPlugin</return>"));
   587 			}
   588 	else if(aErrCode == KErrAuthServNoSuchIdentity)
   589 			{
   590 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAuthServNoSuchIdentity</return>"));
   591 			}
   592 	else if(aErrCode == KErrAuthServPluginCancelled)
   593 			{
   594 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAuthServPluginCancelled</return>"));
   595 			}
   596 	else if(aErrCode == KErrAuthServPluginQuit)
   597 			{
   598 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAuthServPluginQuit</return>"));
   599 			}
   600 	else if(aErrCode == KErrAuthServAuthenticationRequired)
   601 			{
   602 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAuthServAuthenticationRequired</return>"));
   603 			}
   604 	else if(aErrCode == KErrAuthServIdentityAlreadyExists)
   605 			{
   606 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAuthServIdentityAlreadyExists</return>"));
   607 			}
   608 	else if(aErrCode == KErrAuthServIdentityNotFound)
   609 			{
   610 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAuthServIdentityNotFound</return>"));
   611 			}
   612 	else if(aErrCode == KErrAuthServTrainingNotFound)
   613 			{
   614 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAuthServTrainingNotFound</return>"));
   615 			}
   616 	else if(aErrCode == KErrAuthServRegistrationFailed)
   617 			{
   618 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAuthServRegistrationFailed</return>"));
   619 			}
   620 	else if(aErrCode == KErrAuthServCanNotRemoveLastIdentity)
   621 			{
   622 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAuthServCanNotRemoveLastIdentity</return>"));
   623 			}
   624 	else if(aErrCode == KErrAuthServCanNotRemoveLastPlugin)
   625 			{
   626 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAuthServCanNotRemoveLastPlugin</return>"));
   627 			}
   628 	else if(aErrCode == KErrAuthServPluginNotActive)
   629 			{
   630 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAuthServPluginNotActive</return>"));
   631 			}
   632 	else if(aErrCode == KErrAuthServDescTooLong)
   633 			{
   634 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAuthServDescTooLong</return>"));
   635 			}
   636 	else if(aErrCode == KErrUnknownAuthStrengthAlias)
   637 			{
   638 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrUnknownAuthStrengthAlias</return>"));
   639 			}
   640 	else if(aErrCode == KErrAuthStrengthAliasNotDefined)
   641 			{
   642 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAuthStrengthAliasNotDefined</return>"));
   643 			}
   644 	else if(aErrCode == KErrAuthServInvalidAliasStringExpression)
   645 			{
   646 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAuthServInvalidAliasStringExpression/return>"));
   647 			}
   648 	else if(aErrCode == KErrAuthServResetMayLoseIdentity)
   649 			{
   650 			aReturnTag.Copy(_L8("\r\n\t\t<return>KErrAuthServResetMayLoseIdentity/return>"));
   651 			}
   652 #endif
   653 
   654 
   655 //	
   656 	
   657 	return err;
   658 	}
   659 	
   660 // Checks if the first word in RUN_TEST_STEP is an error code. If, then calls GetActionResult().
   661 EXPORT_C TInt Tefinput::ParseActionResult(const TDesC8& aBuf, TDes8& aActionResult)
   662 	{
   663 	TInt errorCode = 0;
   664 	TInt startPos =0;
   665 	
   666 	TPtrC8 data = aBuf.Mid(startPos);
   667 	startPos = data.Find(KEquals);
   668 	if (startPos != KErrNotFound)
   669 		{
   670 		TInt tmp;
   671 		TPtrC8 tmpErrCode = data.Mid(startPos+1);	
   672 		TLex8 lex8(tmpErrCode); 
   673 		tmp = lex8.Val(errorCode);	
   674 		if(tmp != KErrNone)
   675 			{
   676 			return KErrNotFound;
   677 			}
   678 		}
   679 	
   680 	return GetActionResult(errorCode, aActionResult);
   681 	}
   682 	
   683 // Removes any /t, /n and empty spaces from any extracted data.
   684 EXPORT_C TPtrC8 Tefinput::Trim(const TDesC8& aBuf)
   685 	{
   686 	TInt startPos = 0;
   687 	TInt endPos = 0;
   688 	TInt i = 0, j = 0;
   689 		
   690 	for(i = 0; i < aBuf.Length() ; i ++)
   691 		{
   692 		TPtrC8 tmpChar = aBuf.Mid(i,1);
   693 		if(tmpChar != KSpace && tmpChar != KTab && tmpChar != KReturn && tmpChar != KNewline )
   694 			{
   695 			startPos = i;
   696 			break;
   697 			}
   698 		}
   699 	for(j = aBuf.Length()-1; j >= 0 ; j --)
   700 		{
   701 		TPtrC8 tmpChar1 = aBuf.Mid(j,1);
   702 		if(tmpChar1 != KSpace && tmpChar1 != KTab && tmpChar1 != KReturn && tmpChar1 != KNewline )
   703 			{
   704 			endPos = j;
   705 			break;
   706 			}
   707 		}
   708 	if(endPos < startPos)
   709 		{
   710 		endPos = aBuf.Length();
   711 		}
   712 	
   713 
   714 	return aBuf.Mid(startPos, endPos - startPos + 1);
   715 	
   716 	}
   717 	
   718 //Removes '_' between 2 words and adds a space 
   719 EXPORT_C  TDes8 Tefinput::TrimActionType(const TDesC8& aBuf, TDes8& aType)
   720 	{
   721 	TInt startPos = 0;
   722 	TInt pos = 0;
   723 	
   724         // Allocating on heap - since 1024 bytes on stack could be too much for the target.
   725 	HBufC* temp = HBufC::NewLC(512); 
   726 	HBufC* temp2 = HBufC::NewLC(512);	
   727 	
   728 	startPos = aBuf.Find(KUnderScore);
   729 	if(startPos != KErrNotFound)
   730 		{
   731 		temp->Des().Copy(aBuf.Mid(pos,(startPos-pos)));
   732 		temp2->Des().Copy(aBuf.Mid(startPos+1));
   733 		aType.Copy(temp->Des());
   734 		aType.Append(KSpace);
   735 		aType.Append(temp2->Des());
   736 		}
   737 	else
   738 		{
   739 		aType.Copy(aBuf);
   740 		}
   741 
   742         CleanupStack::PopAndDestroy(temp2);                 		
   743         CleanupStack::PopAndDestroy(temp);                 		                 
   744         return aType;          
   745 	}
   746 
   747 //Checks if END_TESTCASE has been reached
   748 EXPORT_C TBool Tefinput::EndTestCase(const TDesC8& aBuf, const TDesC8& aRunStep, const TDesC8& aTag, TInt& aPos)
   749 	{
   750 	TInt startPos =0;
   751 	
   752 	TInt lenRunStep = aRunStep.Length();
   753 	
   754 	TPtrC8 tempScriptFile;
   755 	tempScriptFile.Set(aBuf.Mid(aPos));
   756 	
   757 	startPos = tempScriptFile.Find(aTag);
   758 	if(startPos != KErrNotFound)
   759 		{
   760 		startPos += aPos;
   761 		if(startPos == aPos)
   762 			{
   763 			return ETrue;
   764 			}
   765 		else
   766 			{
   767 			return EFalse;
   768 			}
   769 		}
   770 	else
   771 		{
   772 		return EFalse;
   773 		}
   774 	
   775 	}
   776