|
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 "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 #include <e32base.h> |
|
18 #include <e32cmn.h> |
|
19 #include <f32file.h> |
|
20 |
|
21 #include <stdio.h> |
|
22 |
|
23 #ifndef __EPOC32__ |
|
24 _LIT(KConfigPath,"c:\\System\\Data\\stdcpp_runtest.ini"); |
|
25 #else |
|
26 _LIT(KConfigPath,"z:\\System\\Data\\stdcpp_runtest.ini"); |
|
27 #endif // __EPOC32__ |
|
28 |
|
29 TInt ReadConfig(TLex8& aTlex); |
|
30 TInt RunProcess(TDesC8& achild, TDesC16& aParam, TInt aTimer); |
|
31 |
|
32 |
|
33 TInt E32Main() |
|
34 { |
|
35 TLex8 aTLex; |
|
36 TInt ret; |
|
37 TBuf8<50> child; |
|
38 ret = ReadConfig(aTLex); |
|
39 if(ret) |
|
40 { |
|
41 printf("Failed to Read with Error value %d\n", ret); |
|
42 return -1; |
|
43 } |
|
44 return 0; |
|
45 } |
|
46 |
|
47 |
|
48 TInt ReadConfig(TLex8& aTLex) |
|
49 { |
|
50 |
|
51 TBuf8<5400> data; |
|
52 TInt ret = 0; |
|
53 RFs aRfs; |
|
54 RFile aRfile; |
|
55 TInt asize; |
|
56 TInt tmp, iGiveAwaySum; |
|
57 |
|
58 ret = aRfs.Connect(); |
|
59 |
|
60 if(KErrNone != ret ) |
|
61 { |
|
62 printf("Failure to connect to the file server\n"); |
|
63 return ret; |
|
64 } |
|
65 ret = aRfile.Open(aRfs,KConfigPath,EFileRead); |
|
66 |
|
67 if(KErrNone != ret ) |
|
68 { |
|
69 printf("Failure to open the file\n"); |
|
70 return ret; |
|
71 } |
|
72 ret = aRfile.Size(asize); |
|
73 |
|
74 if(ret != KErrNone) |
|
75 { |
|
76 printf("File with no size\n"); |
|
77 return ret; |
|
78 } |
|
79 |
|
80 if(0 == asize ) |
|
81 { |
|
82 printf("File with no size\n"); |
|
83 return ret; |
|
84 } |
|
85 |
|
86 ret = aRfile.Read(data, asize); |
|
87 if(ret != KErrNone) |
|
88 { |
|
89 printf("Cannot read the complete file\n"); |
|
90 return ret; |
|
91 } |
|
92 aTLex.Assign(data); |
|
93 TChar chr; |
|
94 TBuf8<50> copybuf; |
|
95 TBuf16<50> copybuf1; |
|
96 while (!aTLex.Eos()) |
|
97 { |
|
98 TPtrC8 nexttoken = aTLex.NextToken(); |
|
99 copybuf.Copy(nexttoken); |
|
100 TPtrC8 adata = aTLex.NextToken(); |
|
101 TLex8 numLexer(adata); |
|
102 if (numLexer.Val(tmp) == KErrNone) |
|
103 { |
|
104 iGiveAwaySum = tmp; |
|
105 } |
|
106 else |
|
107 { |
|
108 //nada |
|
109 } |
|
110 TPtrC8 nexttoken1 = aTLex.NextToken(); |
|
111 copybuf1.Copy(nexttoken1); |
|
112 RunProcess(copybuf, copybuf1, tmp); |
|
113 } |
|
114 return ret; |
|
115 } |
|
116 |
|
117 |
|
118 TInt RunProcess(TDesC8& achild, TDesC16& aparam, TInt atimer) |
|
119 { |
|
120 TFileName childpath; |
|
121 childpath.Copy(achild); |
|
122 TInt ret = 0; |
|
123 RProcess process; |
|
124 TRequestStatus processstatus, timerstatus; |
|
125 ret = process.Create(childpath, aparam); |
|
126 process.Resume(); |
|
127 process.Logon(processstatus); |
|
128 RTimer timeout; |
|
129 timeout.CreateLocal(); |
|
130 timeout.After(timerstatus, atimer*1000000); |
|
131 User::WaitForRequest(processstatus, timerstatus); |
|
132 if (processstatus == KRequestPending) |
|
133 { |
|
134 process.LogonCancel(processstatus); |
|
135 process.Kill(KErrTimedOut); |
|
136 } |
|
137 else |
|
138 { |
|
139 timeout.Cancel(); |
|
140 } |
|
141 process.Close(); |
|
142 timeout.Close(); |
|
143 return 0; |
|
144 |
|
145 } |
|
146 |