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