sl@0: /* sl@0: * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include sl@0: sl@0: #ifndef __EPOC32__ sl@0: _LIT(KConfigPath,"c:\\System\\Data\\stdcpp_runtest.ini"); sl@0: #else sl@0: _LIT(KConfigPath,"z:\\System\\Data\\stdcpp_runtest.ini"); sl@0: #endif // __EPOC32__ sl@0: sl@0: TInt ReadConfig(TLex8& aTlex); sl@0: TInt RunProcess(TDesC8& achild, TDesC16& aParam, TInt aTimer); sl@0: sl@0: sl@0: TInt E32Main() sl@0: { sl@0: TLex8 aTLex; sl@0: TInt ret; sl@0: TBuf8<50> child; sl@0: ret = ReadConfig(aTLex); sl@0: if(ret) sl@0: { sl@0: printf("Failed to Read with Error value %d\n", ret); sl@0: return -1; sl@0: } sl@0: return 0; sl@0: } sl@0: sl@0: sl@0: TInt ReadConfig(TLex8& aTLex) sl@0: { sl@0: sl@0: TBuf8<5400> data; sl@0: TInt ret = 0; sl@0: RFs aRfs; sl@0: RFile aRfile; sl@0: TInt asize; sl@0: TInt tmp, iGiveAwaySum; sl@0: sl@0: ret = aRfs.Connect(); sl@0: sl@0: if(KErrNone != ret ) sl@0: { sl@0: printf("Failure to connect to the file server\n"); sl@0: return ret; sl@0: } sl@0: ret = aRfile.Open(aRfs,KConfigPath,EFileRead); sl@0: sl@0: if(KErrNone != ret ) sl@0: { sl@0: printf("Failure to open the file\n"); sl@0: return ret; sl@0: } sl@0: ret = aRfile.Size(asize); sl@0: sl@0: if(ret != KErrNone) sl@0: { sl@0: printf("File with no size\n"); sl@0: return ret; sl@0: } sl@0: sl@0: if(0 == asize ) sl@0: { sl@0: printf("File with no size\n"); sl@0: return ret; sl@0: } sl@0: sl@0: ret = aRfile.Read(data, asize); sl@0: if(ret != KErrNone) sl@0: { sl@0: printf("Cannot read the complete file\n"); sl@0: return ret; sl@0: } sl@0: aTLex.Assign(data); sl@0: TChar chr; sl@0: TBuf8<50> copybuf; sl@0: TBuf16<50> copybuf1; sl@0: while (!aTLex.Eos()) sl@0: { sl@0: TPtrC8 nexttoken = aTLex.NextToken(); sl@0: copybuf.Copy(nexttoken); sl@0: TPtrC8 adata = aTLex.NextToken(); sl@0: TLex8 numLexer(adata); sl@0: if (numLexer.Val(tmp) == KErrNone) sl@0: { sl@0: iGiveAwaySum = tmp; sl@0: } sl@0: else sl@0: { sl@0: //nada sl@0: } sl@0: TPtrC8 nexttoken1 = aTLex.NextToken(); sl@0: copybuf1.Copy(nexttoken1); sl@0: RunProcess(copybuf, copybuf1, tmp); sl@0: } sl@0: return ret; sl@0: } sl@0: sl@0: sl@0: TInt RunProcess(TDesC8& achild, TDesC16& aparam, TInt atimer) sl@0: { sl@0: TFileName childpath; sl@0: childpath.Copy(achild); sl@0: TInt ret = 0; sl@0: RProcess process; sl@0: TRequestStatus processstatus, timerstatus; sl@0: ret = process.Create(childpath, aparam); sl@0: process.Resume(); sl@0: process.Logon(processstatus); sl@0: RTimer timeout; sl@0: timeout.CreateLocal(); sl@0: timeout.After(timerstatus, atimer*1000000); sl@0: User::WaitForRequest(processstatus, timerstatus); sl@0: if (processstatus == KRequestPending) sl@0: { sl@0: process.LogonCancel(processstatus); sl@0: process.Kill(KErrTimedOut); sl@0: } sl@0: else sl@0: { sl@0: timeout.Cancel(); sl@0: } sl@0: process.Close(); sl@0: timeout.Close(); sl@0: return 0; sl@0: sl@0: } sl@0: