void CVBookmarkConverter::IgnoreSpaces( TPtrC8& aData )
    {
    TInt last = aData.Length() - 1;
    
    TInt begin;
    for ( begin = 0; begin <= last; begin++ )
        {
        if ( !TChar( aData[begin] ).IsSpace() )
            {
            break;
            }
        }
        
    TInt end;   
    for ( end = last; end >= 0; end-- )
        {
        if ( !TChar( aData[end] ).IsSpace() )
            {
            break;
            }
        }
        
    TInt length = end - begin + 1;  
                
    if ( ( begin != 0 || end != last ) && length > 0 )
        {
        TPtrC8 newData = aData.Mid( begin, length );
        aData.Set( newData );
        }
    }
Esempio n. 2
0
/**
Opens the exported file and compares it with expected vCard file passed as argument.
*/
void CCntPBAPSupport::CompareFilesL(RReadStream& aCompareStream)
	{
	RFile exportedFile;	
	TInt err = exportedFile.Open(iFsSession, KTempExportFile(), EFileRead);
	if (err != KErrNone)
		{
		ReportFileErrorL(err, KTempExportFile());	
		}
	CleanupClosePushL(exportedFile);
	RFileReadStream stream1(exportedFile);
	CleanupClosePushL(stream1);

	TBuf8<0x80> bufO,bufC;
	
	TInt line = 1;
	do {
		TRAP(err, stream1.ReadL(bufO, TChar(0xa)));
		if (err == KErrNone || err == KErrEof)
			{
			TRAP(err, aCompareStream.ReadL(bufC, TChar(0xa)));	
			}
		if (err != KErrNone && err != KErrEof)
			{
			User::Leave(err);	
			}
		test(CompareLines(bufO, bufC));
		++line;
		} while (err != KErrEof);
	CleanupStack::PopAndDestroy(2,&exportedFile);
	}
Esempio n. 3
0
void CWordTest::ToggleCaseL(CEikRichTextEditor* aEditor)
{
    TCursorSelection sel = aEditor->Selection();
    int start = sel.LowerPos();
    int end = start;
    TBool to_upper = TRUE;
    while (end < sel.HigherPos())
    {
        TPtrC text;
        TCharFormat f;
        aEditor->RichText()->GetChars(text,f,start);
        int length = text.Length();
        if (start + length > sel.HigherPos())
            length = sel.HigherPos() - start;
        end = start + length;
        if (start == sel.LowerPos() && end > start)
        {
            if (TChar(text[0]).IsUpper())
                to_upper = FALSE;
        }
        TText* p = (TText*)text.Ptr();
        TText* q = p + length;
        while (p < q)
        {
            if (to_upper)
                *p = (TText)(TChar(*p).GetUpperCase());
            else
                *p = (TText)(TChar(*p).GetLowerCase());
            p++;
        }

        start = end;
    }
    aEditor->TextView()->HandleRangeFormatChangeL(sel);
}
//This function is used in the test code to kill ECOMSERVER
//processes (or some other) when they leftover and may problem in ECOMSERVERTEST
static TInt KillProcess(const TDesC& aProcessName)
	{
	TFullName name;

	RDebug::Print(_L("Find and kill \"%S\" process.\n"), &aProcessName);

	TBuf<64> pattern(aProcessName);
	TInt length = pattern.Length();
	pattern += _L("*");
	TFindProcess procFinder(pattern);

	while(procFinder.Next(name) == KErrNone)
		{
		if(name.Length() > length) 
			{
			//If found name is a string containing aProcessName string.
			TChar c(name[length]);
			if(c.IsAlphaDigit() || c == TChar('_') || c == TChar('-'))
				{
				//If the found name is other valid application name starting with aProcessName string.
				RDebug::Print(_L(":: Process name: \"%S\".\n"), &name);
				continue;
				}
			}
		RProcess proc;
		if(proc.Open(name) == KErrNone)
			{
			proc.Kill(0);
			RDebug::Print(_L("\"%S\" process killed.\n"), &name);
			}
		proc.Close();
		}
	return KErrNone;
	}
void CAreaSearchResult::ConstructL(const TDesC& aDes) 
    {
    TLex line(aDes);
    line.Mark();
    TInt redefined=0;

    if (line.Peek() != '#' && line.Peek() != '\t')
        { 
        TInt index=0;
        while (line.Peek() != '\n' && !(line.Peek()).Eos())
            {
            line.Inc();
            if (line.Peek() == '\t')
                {
                TPtrC token = line.MarkedToken();
                TLex val(token);              
                switch(index)
                    {
                    case ESouthLat:
                        val.Val(iSouthLat, TChar(','));   
                        break;
                    case ENorthLat:
                        val.Val(iNorthLat, TChar(','));   
                        break;
                    case EWestLong:
                        val.Val(iWestLong, TChar(','));   
                        break;
                    case EEastLong:
                        val.Val(iEastLong, TChar(','));   
                        break;
                    case EErrorCode:
                        val.Val(iErrorCode);   
                        break;
                    case ESearchResult:
                        ParseSearchResult(token);
                        break;
                    case ERedefined:
                        val.Val(redefined);
                        if (redefined == 1)
                            {
                            iRedefined = ETrue;
                            }
                        break;
                    }    
                line.Inc();
                while (line.Peek() == '\t') // Empty value
                    {
                    line.Inc();
                    ++index;
                    }
                line.Mark();
                ++index;
                }
            }
        }
    
    }
Esempio n. 6
0
void CSqlCmdAttach::OptionsL(RCommandOptionList& aOptions)
	{
	_LIT(KOptFile, "file");
	_LIT(KOptFileDescription, "Specify additional database file.");
	aOptions.AppendStringL(iOptFileName, TChar('f'), KOptFile, KOptFileDescription);

	_LIT(KOptDB, "name");
	_LIT(KOptDBDescription, "Specify additional database name.");
	aOptions.AppendStringL(iOptDBName, TChar('n'), KOptDB, KOptDBDescription);
	}
Esempio n. 7
0
void CSqlCmdState::OptionsL(RCommandOptionList& aOptions)
	{
	_LIT(KOptFile, "temp");
	_LIT(KOptFileDescription, "Specify TEMP file template(used to dump large binary content to file)");
	aOptions.AppendStringL(iOptFileName, TChar('t'), KOptFile, KOptFileDescription);
	
	_LIT(KOptParam, "param");
	_LIT(KOptParamDescription, "Specify file names, of which the content will be used to fill parameters in SQL statement");
	aOptions.AppendStringL(iOptParamFile, TChar('p'), KOptParam, KOptParamDescription);
	}
Esempio n. 8
0
TInt TEnvVar::Externalize(TDes16& aBuffer)
	{
	if (iName==0) 
		return 0;
	aBuffer.Append(*iName);
	aBuffer.Append(TChar(0));
	aBuffer.Append(*iValue);
	aBuffer.Append(TChar(0));
	return 1;
	}
Esempio n. 9
0
TBool IsProcessRunning(const TDesC& aProcessName)
	{
	TFullName name;
	TBool IsProcessRunning(EFalse);
	TBuf<64> pattern(aProcessName);
	TInt length = pattern.Length();
	pattern += _L("*");
	TFindProcess procFinder(pattern);

	while(procFinder.Next(name) == KErrNone)
		{
		if(name.Length() > length)
			{//If found name is a string containing aProcessName string.
			TChar c(name[length]);
			if(c.IsAlphaDigit() || c == TChar('_') || c == TChar('-'))
				{//If the found name is other valid application name starting with aProcessName string.
				RDebug::Print(_L(":: Process name: \"%S\".\n"), &name);
				continue;
				}
			}
		RProcess proc;
		if(proc.Open(name) == KErrNone)
			{
			if (EExitKill == proc.ExitType())
			    {
			    RDebug::Print(_L("\"%S\" process killed.\n"), &name);
			    proc.Close();
			    IsProcessRunning = EFalse;
			    }
			 else
			    {
			    IsProcessRunning = ETrue;
			    RDebug::Print(_L("\"%S\" process is running.\n"), &name);
			    }

			if(IsProcessRunning)
				{
				RDebug::Print(_L("Waiting additional time...\n"), &name);

				User::After(1000000);

				if (EExitKill == proc.ExitType())
					{
					RDebug::Print(_L("\"%S\" process now killed.\n"), &name);
			    	IsProcessRunning = EFalse;
					}

				proc.Close();
				}
			}


		}
	return IsProcessRunning;
	}
Esempio n. 10
0
void epoc_gcvt( double x, int digits, unsigned char *buf) {
    TRealFormat trel;

    trel.iPlaces = digits;
    trel.iPoint = TChar( '.');

    TPtr result( buf, 80);

    result.Num( x, trel);
    result.Append( TChar( 0));
  }
Esempio n. 11
0
inline TBool IsAdaptiveFindMatchClassic( const TDesC& aItemString, const TDesC& aSearchText )
    {
    TPtrC itemptr = aItemString;
    TPtrC searchptr = aSearchText;

    TBool match = EFalse;
    
    for(;;) 
        {
        // Loop invariant: itemptr is next character from ' ' or '-'
        // Loop invariant: seachptr is at beginning of searched item
    
        TInt val = MyFindC(itemptr,searchptr);
        if (val == 0)
            {
            match = ETrue;
            break;
            }
        if (val != KErrNotFound && IsFindWordSeparator(itemptr[val-1]))
            {
            match = ETrue;
            break;
            }

        // find the word separator characters from list item
        TInt spacepos = itemptr.LocateF(TChar(' '));
        TInt minuspos = itemptr.LocateF(TChar('-'));
        TInt tabpos = itemptr.LocateF(TChar('\t'));
        if (spacepos != KErrNotFound)
            {
            itemptr.Set(itemptr.Mid(spacepos+1));
            }
        else if (minuspos != KErrNotFound)
            {
            itemptr.Set(itemptr.Mid(minuspos+1));
            }
        else if (tabpos != KErrNotFound)
            {
            itemptr.Set(itemptr.Mid(tabpos+1));
            }
        else
            {
            match = EFalse;
            break;
            }
        if (itemptr.Length() == 0)
            {
            match = EFalse;
            break;
            }

        }
    return match;
    }	
Esempio n. 12
0
/* Workaround for defect atof(), see java defect list for epoc */
double epoc_atof( char* str) {
    TReal64 aRes;
    
    while (TChar( *str).IsSpace()) {
      str++;
    }

    TLex lex( _L( str));
    TInt err = lex.Val( aRes, TChar( '.'));
    return aRes;
}
/*!

 */
void SettingsUtility::setDateSeparator(const QString &separator)
{
	OstTraceFunctionEntry0( SETTINGSUTILITY_SETDATESEPARATOR_ENTRY );
	TLocale locale;
	locale.SetDateSeparator(
			TChar(separator.unicode()->unicode()), 1);
	locale.SetDateSeparator(
			TChar(separator.unicode()->unicode()), 2);
	locale.Set();
	OstTraceFunctionExit0( SETTINGSUTILITY_SETDATESEPARATOR_EXIT );
}
Esempio n. 14
0
/**
@SYMTestCaseID SYSLIB-DBMS-CT-0008
@SYMTestCaseDesc Database tests. Some of the calls must fail because the caller has no enough rights
                 for the requested operation.
@SYMTestPriority High
@SYMTestActions  RDbNamedDatabase::Open()/RDbNamedDatabase::DatabaseNamesL()/RDbNamedDatabase::Create().
@SYMTestExpectedResults The test must not fail.
@SYMREQ REQ2429
                 DBMS shall provide an API to apply security policies to database tables.
*/
static void DbTestL()
	{
	TBuf<32> format;

	TDBSCUtils::DeleteDatabase(TheDbs, KSecureDbUid, KDbName);
	TheTest.Printf(_L("Create database\n"));
	//The test must pass, because the test app has "SCHEMA" capability
	format.Copy(KSecure);
	format.Append(KSecureDbUid.Name());
	TInt err = TheDb.Create(TheDbs, KDbName, format);
	TEST2(err, KErrNone);

	//The test must pass, because "DatabaseNamesL" is a DBMS operation available for everyone.
	TheTest.Printf(_L("Database list\n"));
	CDbDatabaseNames* dbNames = TheDbs.DatabaseNamesL(EDriveC, KSecureDbUid);
	TEST(dbNames->Count() > 0);
	TBool casePreserved = EFalse;
	for(TInt i=0;i<dbNames->Count();++i)
		{
		const TDesC& dbName = (*dbNames)[i];
		RDebug::Print(_L("--Database: %S\n"), &dbName);
		TBuf<128> dbName2;
		dbName2.Append(TChar('A' + EDriveC));
		dbName2.Append(TChar(':'));
		dbName2.Append(dbName);
		if(dbName2 == KDbName())
			{
			casePreserved = ETrue;
			}
		}
	//if casePreserved is non-zero that means the DBMS server does not change the database names to
	//upper or lower case - that's what we want to check
	TEST(casePreserved);
	delete dbNames;

	TheDb.Close();

	TheTest.Printf(_L("An attempt to create database - existing, but protected UID\n"));
	//The test must fail, because the test app does not have capabilities to satisfy
	//KProtSecureDbUid "SCHEMA" policy.
	format.Copy(KSecure);
	format.Append(KProtSecureDbUid.Name());
	err = TheDb.Create(TheDbs, KDbName, format);
	TEST2(err, KErrPermissionDenied);

	//The test must pass, because the test app has "SCHEMA" capability (it must have capabilities,
	//satisfying at least one of the UID's R/W/S policies)
	TheTest.Printf(_L("Open database\n"));
	format.Copy(KSecure);
	format.Append(KSecureDbUid.Name());
	err = TheDb.Open(TheDbs, KDbName, format);
	TEST2(err, KErrNone);
	}
/*!

 */
void SettingsUtility::setTimeSeparator(const QString &separator)
{
	OstTraceFunctionEntry0( SETTINGSUTILITY_SETTIMESEPARATOR_ENTRY );
	if (mTimeSeparatorList.contains(separator)) {
	    TLocale locale;

		locale.SetTimeSeparator(TChar(separator.unicode()->unicode()), 1);
		locale.SetTimeSeparator(TChar(separator.unicode()->unicode()), 2);

		locale.Set();
    }
	OstTraceFunctionExit0( SETTINGSUTILITY_SETTIMESEPARATOR_EXIT );
}
Esempio n. 16
0
GLDEF_C TInt E32Main()
	{
	test.Title();
	TBuf<256> cmd;
	TFullName fn;
	User::CommandLine(cmd);
	TLex lex(cmd);
	TPtrC threadSpec(lex.NextToken());
	TFindThread ft(threadSpec);
	TExitType exitType=EExitKill;
	TInt exitCode=0;
	if (!lex.Eos())
		{
		TPtrC xtSpec(lex.NextToken());
		TPtrC xc(xtSpec);
		TChar xt0=xtSpec[0];
		if (xt0.IsAlpha())
			{
			xt0.LowerCase();
			if (xt0==TChar('t'))
				exitType=EExitTerminate;
			else if (xt0==TChar('p'))
				exitType=EExitPanic;
			new(&xc) TPtrC(lex.NextToken());
			}
		if (xc.Length())
			{
			TLex lex2(xc);
			lex2.Val(exitCode);
			}
		}
	while (ft.Next(fn)==KErrNone)
		{
		test.Printf(_L("Killing %S\n"),&fn);
		RThread t;
		TInt r=t.Open(ft);
		if (r==KErrNone)
			{
			// FIXME: SHOULD REMOVE CRITICALNESS - WOULD NEED DEVICE DRIVER
			switch (exitType)
				{
				case EExitKill:	t.Kill(exitCode); break;
				case EExitTerminate: t.Terminate(exitCode); break;
				case EExitPanic: t.Panic(KPanicCat,exitCode); break;
				default: break;
				}
			t.Close();
			}
		}
	return 0;
	}
Esempio n. 17
0
TInt CDMCertNotifier::GetCert( TCertInfo& aCertInfo )
    {
	RDEBUG("CDMUtilServer::GetCertFromCentRep");
	
#ifdef __TARM_SYMBIAN_CONVERGENCY
	TPckg<TCertInfo> pcert( aCertInfo );
	pcert.Fill( TChar( 0 ) );
	return iCertificateProperty.Get( pcert );
#else	
    TPckg<TCertInfo> certp( aCertInfo );
    certp.Fill( TChar( 0 ) );
	return iRepository->Get( KSyncMLSessionCertificate, certp );
#endif
    }
 int WordBreakIteratorSymbian::previous() {
     if (currentPos == 0) {
         currentPos = -1;
         return currentPos;
     }
     bool haveSpace = false;
     while (currentPos > 0) {
         if (haveSpace && !TChar(string[currentPos]).IsSpace())
             break;
         if (TChar(string[currentPos]).IsSpace())
             haveSpace = true;
         --currentPos;
     }
     return currentPos;
 }
 int WordBreakIteratorSymbian::next() {
     if (currentPos == length) {
         currentPos = -1;
         return currentPos;
     }
     bool haveSpace = false;
     while (currentPos < length) {
         if (haveSpace && !TChar(string[currentPos]).IsSpace())
             break;
         if (TChar(string[currentPos]).IsSpace())
             haveSpace = true;
         ++currentPos;
     }
     return currentPos;
 }
Esempio n. 20
0
void CSTTorrentManager::GeneratePeerIdL()
{
	iPeerId.Append(SYMTORRENT_PEER_ID_VERSION);
	
	for (TInt i=0; i<12; i++)	
		iPeerId.Append(TChar( TUint(Math::Rand(iSeed)) % 25 + 97 )); // random smaller case alphabatic characters ('a' - 'z')
}
Esempio n. 21
0
LOCAL_C TInt findWordSplitterL(TAny *aParams)
	{
	SFindInTextDefWordParser *parser=(SFindInTextDefWordParser *)aParams;
	const TText *ptr=parser->iSearchString->Ptr();
	const TText *end=ptr+parser->iSearchString->Length();
	const TText *startOfWord=NULL;
	FOREVER
		{
		if (ptr==end || !TChar(*ptr).IsAlphaDigit())
			{
			if (startOfWord)
				{
				TPtrC addWord(startOfWord,ptr-startOfWord);
				parser->iWordArray->AppendL(addWord);
				startOfWord=NULL;
				}
			if (ptr==end)
				break;
			}
		else if (!startOfWord)
			startOfWord=ptr;
		ptr++;
		}
	return(KErrNone);
	}
Esempio n. 22
0
TInt CEventLogger::UpdateLogEventParam(CLogEvent& aLogEvent, TInt aRConnectionStatusId, const TUid& aDataEventType, const TInt64& aBytesSent, const TInt64& aBytesReceived)
{

    TTime time;
    TInt ret =KErrNone;
    time.UniversalTime();
    TTimeIntervalSeconds interval(0);
    if (time.SecondsFrom(iCurrentLogEvent->Time(),interval) != KErrNone)
    {
        interval = 0;	// no duration available ->error
    }
    if (KConnectionStatusIdNotAvailable != aRConnectionStatusId)
    {
        //status needs to be updated
        TBuf<KLogMaxStatusLength > logStatusBuf;
        iLogWrap->Log().GetString(logStatusBuf, aRConnectionStatusId); // Ignore error - string blank on error which is ok
        aLogEvent.SetStatus(logStatusBuf);
    }
    if ( aDataEventType != TUid::Null())
    {
        aLogEvent.SetEventType(aDataEventType);
    }
    aLogEvent.SetDuration(interval.Int());		//0 or not
    //check if data metrics need to be updated
    TInt64 byteInfoNotAvailable(KBytesInfoNotAvailable);
    if ((aBytesReceived != byteInfoNotAvailable) && (aBytesSent != byteInfoNotAvailable))
    {
        TBuf8<KDatabufferSize> dataBuffer;
        dataBuffer.Num(aBytesSent);
        dataBuffer.Append(TChar(','));
        dataBuffer.AppendNum(aBytesReceived);
        TRAP(ret, aLogEvent.SetDataL(dataBuffer));
    }
    return ret;
}
// ---------------------------------------------------------
// CPosLmLocalDatabaseManager::DatabaseDrive
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
TChar CPosLmLocalDatabaseManager::DatabaseDrive(
    const TDesC&  aDatabaseUri)
    {
    TChar sysDriveChar = RFs::GetSystemDriveChar();
    
    // if protocol delimiter present,
    // verify that URI starts with "file://"
    TInt offset = aDatabaseUri.Find(KProtocolDelimiter);
    if (offset != KErrNotFound && aDatabaseUri.Left(offset) != KFileProtocol)
        {
        // wrong protocol
        return 0;
        }

    // adjust offset depending on whether or not protocol is present
    offset = offset == KErrNotFound ?
             0 :
             KFileProtocol().Length() + KProtocolDelimiter().Length();

    if (aDatabaseUri.Length() < offset + KDriveAndDelimiterLength)
        {
        return 0;
        }

    // if second character is ":", return first character
    // otherwise return default drive
    if (aDatabaseUri[offset + 1] == KDriveDelimiter)
        {
        return TChar(aDatabaseUri[offset]).GetUpperCase();
        }
    return sysDriveChar;
    }
Esempio n. 24
0
EXPORT_C TInt CTestConfig::GetElement(const TDesC8& aInput, TChar aDelimiter, TInt aIndex, TPtrC8& aOutput, TBool aTrimOutput)
	{
	TLex8 input(aInput);
	TInt err = KErrNone;
	TPtrC8 ptr;

	for (TInt i = 0; i <= aIndex && err == KErrNone; i++)
		{
		err = GetNextElement(input, aDelimiter, ptr);
		}

	if (err == KErrNone)
		{
		if (aTrimOutput)
			aOutput.Set(Trim(ptr));
		else
			aOutput.Set(ptr);
		}
	else 
		{
		const TInt count = CountElements(aInput, aDelimiter);
		const TInt len = aInput.Length();

		if (len != 0 && count - 1 == aIndex && TChar(aInput[len-1]) == aDelimiter)
			{
			aOutput.Set(KNullDesC8);
			err = KErrNone;
			}
		}

	return err;
	}
Esempio n. 25
0
EXPORT_C TPtrC8 CTestConfig::TrimLeft(const TDesC8& aInput)
	{
	const TText8* first = aInput.Ptr();					// pointer to first char
	const TText8* last = first + aInput.Length() - 1;		// pointer to last char
	while (first < last && TChar(*first).IsSpace()) first++;	// trim the left
	return TPtrC8(first, last + 1 - first);				// return the result
	}
Esempio n. 26
0
TInt CATSmsCommands::CMSErrorValue()
/*
 * Returns the error code decoded from the response string .eg '+CMS ERROR: xxx'.
 * This functions considers '+CMS ERROR: 500' and 'ERROR' as the error 500.
 * @return if there was an error the ETSI or KErr error value
 * @return if there was not an error then KErrNone
  */
 	{
	LOCAL_LOGTEXT("CMSErrorValue","enter function");
	// Locate error string
	iBuffer.Set(iIo->Buffer());
	TInt pos=iBuffer.FindF(KERRORResponseString);
	if (pos==KErrNotFound)
		return KErrNone;		// If we can't find the 'ERROR' string then that means there was not an error ;-)
	
	// Locate error value
	// (ie. read in all digits form the first found to the end of the string)
	const TInt length=iBuffer.Length();
	pos+=KCMGSResponseStringLength;
	while(pos<length && !(TChar(iBuffer[pos]).IsDigit()))
		pos++;
	
	TInt ret=500;		// 500 is the error value for 'undefined'
	if(pos<length) 	// Only decode error value if we found some digits
		{
		TLex8 lex(iBuffer.Mid(pos));
		TUint16 val;
		if(lex.Val(val,EDecimal)==KErrNone)
			ret=val;
		}
	
	LOGTEXT2(_L8("CATSmsCommands::CmsErrorValue\terror = %d"),ret);
	return ret;
	}
void CReferencePolicyPlugin::AvailableDriveListL()
    {
    OstTraceFunctionEntry0( REF_CREFERENCEPOLICYPLUGIN_AVAILABLEDRIVELISTL_ENTRY );
    
    TBuf8<KPermittedDrvRangeBufLen> permittedRange;
    TDriveList forbiddenList;

    PrepareAvailableDriveList();

    User::LeaveIfError(iRepository->Get(KPermittedRangeUid, permittedRange));
    User::LeaveIfError(iRepository->Get(KForbiddenListUid, forbiddenList));

    for (TInt index = 'A'; index <= 'Z'; index++ )
        {
        if ((index >= permittedRange[0]) && (index <= permittedRange[1]))
            {
            if (KErrNotFound == forbiddenList.Locate(TChar(index)))
                {
                // Permitted
                iAvailableDrvList[index - 'A'] = 0x01;
                }
            }
        }
    OstTraceFunctionExit0( REF_CREFERENCEPOLICYPLUGIN_AVAILABLEDRIVELISTL_EXIT );
    }
Esempio n. 28
0
// -----------------------------------------------------------------------------
// SdpUtil::IsValidNtpTime
// Checks if aValue contains only non-whitespace characters
// -----------------------------------------------------------------------------
//
TBool SdpUtil::IsValidNtpTime(
    const TDesC8& aValue )
	{
	// POS-DIGIT 9*DIGIT
	TUint len = aValue.Length();
	TBool result = len >= 10 && TChar( aValue[0] ) != TChar('0');
	if ( result )
		{
		for ( TUint i( 0 ); result && i < len; i++)
			{
			TInt tmp = aValue[i] - '0';
			result = ( tmp >= 0 && tmp <= 9 );
			}
		}
	return result;
	}
Esempio n. 29
0
LOCAL_C void ProfileAllThreads()
	{
	TFindThread ft(_L("*"));
	TFullName fullname;
	test.Console()->ClearScreen();
	FOREVER
		{
		TInt r=ft.Next(fullname);
		if (r!=KErrNone)
			break;
		RThread t;
		r=t.Open(ft);
		if (r==KErrNone)
			{
			TProfileData data;
			r=Profile.Read(t,data);
			if (r==KErrNone)
				{
				while(fullname.Length()<40)
					fullname.Append(TChar(' '));
				test.Printf(_L("%S T=%9d C=%9d Y=%9d\n"),
					&fullname,data.iTotalCpuTime,data.iMaxContinuousCpuTime,data.iMaxTimeBeforeYield);
				}
			t.Close();
			}
		}
	}
Esempio n. 30
0
EXPORT_C int
wcwidth(wchar_t wc)
{
	int rVal,result = 0;
	TChar::TCjkWidth rWid;
		
	//check for end of string
	if(wc == L'\0')
	{
		return (result);
	}
	
	//check if the character is printable
	rVal = iswprint((wint_t)wc);

	//if printable
	if(rVal)
	{
		rWid = (TChar::TCjkWidth)TChar((TUint)wc).GetCjkWidth();
		if(rWid == TChar::ENarrow)
		{
			result = TChar::EHalfWidth;
		}
		if(rWid == TChar::EWide)
		{
			result = TChar::EFullWidth;
		}
	}
	else
	{
		result = -1;//if the character is not printable
	}
	
	return (result);
}