21 #ifndef __R_OBEY_H__ |
21 #ifndef __R_OBEY_H__ |
22 #define __R_OBEY_H__ |
22 #define __R_OBEY_H__ |
23 |
23 |
24 #define __REFERENCE_CAPABILITY_NAMES__ |
24 #define __REFERENCE_CAPABILITY_NAMES__ |
25 |
25 |
26 #ifdef _MSC_VER |
|
27 #pragma warning(disable:4503) |
|
28 #endif |
|
29 |
|
30 #if defined(__MSVCDOTNET__) || defined(__TOOLS2__) |
|
31 #include <fstream> |
|
32 #else |
|
33 #include <fstream.h> |
|
34 #endif |
|
35 |
|
36 #include <stdio.h> |
26 #include <stdio.h> |
37 #include <e32capability.h> |
27 #include <e32capability.h> |
38 |
28 #include <kernel/kernboot.h> |
39 #ifdef _L |
|
40 #undef _L |
|
41 #endif |
|
42 |
29 |
43 #include <vector> |
30 #include <vector> |
44 #include <map> |
31 #include <map> |
45 #include <kernel/kernboot.h> |
32 #include <fstream> |
46 |
33 |
|
34 using namespace std; |
47 // |
35 // |
48 const TUint32 KNumWords=16; |
36 const TUint32 KNumWords=16; |
49 // |
37 // |
50 const TInt KDefaultRomSize=0x400000; |
38 const TInt KDefaultRomSize=0x400000; |
51 const TInt KDefaultRomAlign=0x10; |
39 const TInt KDefaultRomAlign=0x10; |
52 // |
40 // |
53 |
41 typedef vector<string> StringVector ; |
54 typedef std::string String; |
42 typedef map<string, StringVector> KeywordMap; |
55 typedef std::vector<String> StringVector; |
|
56 typedef std::map<String, StringVector> KeywordMap; |
|
57 |
43 |
58 enum EKeyword |
44 enum EKeyword |
59 { |
45 { |
60 EKeywordNone=0, // backwards compatibility, but now ignored |
46 EKeywordNone=0, // backwards compatibility, but now ignored |
61 EKeywordFile, |
47 EKeywordFile, |
144 }; |
130 }; |
145 |
131 |
146 class ObeyFileReader |
132 class ObeyFileReader |
147 { |
133 { |
148 public: |
134 public: |
149 ObeyFileReader(TText *aFileName); |
135 ObeyFileReader(const char *aFileName); |
150 ~ObeyFileReader(); |
136 ~ObeyFileReader(); |
151 |
137 |
152 static void KeywordHelp(); |
138 static void KeywordHelp(); |
153 |
139 |
154 TBool Open(); |
140 TBool Open(); |
155 void Mark(); |
141 void Mark(); |
156 void MarkNext(); |
142 void MarkNext(); |
157 void Rewind(); |
143 void Rewind(); |
158 |
144 |
159 TInt NextLine(TInt aPass, enum EKeyword& aKeyword); |
145 TInt NextLine(TInt aPass, enum EKeyword& aKeyword); |
160 TInt NextAttribute(TInt& aIndex, TInt aHasFile, enum EFileAttribute& aKeyword, TText*& aArg); |
146 TInt NextAttribute(TInt& aIndex, TInt aHasFile, enum EFileAttribute& aKeyword, char*& aArg); |
161 |
147 |
162 void CopyWord(TInt aIndex, TText*& aString); // allocate copy of nth word |
148 char* DupWord(TInt aIndex) const; // allocate copy of nth word |
163 TInt Count() { return iNumWords;} // number of words on current line |
149 TInt Count() const { return iNumWords;} // number of words on current line |
164 char* Word(TInt aIndex) { return (char*)iWord[aIndex]; } // return nth word as char* |
150 const char* Word(TInt aIndex) const { return iWord[aIndex]; } // return nth word as char* |
165 TText* Text(TInt aIndex) { return iWord[aIndex]; } // return nth word as TText* |
151 const char* Suffix() const { return iSuffix; } // return unmatched suffix of word[0] |
166 char* Suffix() { return (char*)iSuffix; } // return unmatched suffix of word[0] |
152 TInt CurrentLine() const { return iCurrentLine;} // number of words on current line |
167 TInt CurrentLine() { return iCurrentLine;} // number of words on current line |
153 const char* GetCurrentObeyStatement() const {return iCurrentObeyStatement;} // return current obey statement |
168 TText* GetCurrentObeyStatement() const; // return current obey statement |
|
169 |
154 |
170 void ProcessTime(TInt64& aTime); |
155 void ProcessTime(TInt64& aTime); |
171 |
|
172 static void TimeNow(TInt64& aTime); |
156 static void TimeNow(TInt64& aTime); |
173 private: |
157 private: |
174 TInt ReadAndParseLine(); |
158 TInt ReadAndParseLine(); |
175 TInt SetLineLengthBuffer(); |
|
176 TInt Parse(); |
159 TInt Parse(); |
177 inline TBool IsGap(char ch); |
160 inline static TBool IsGap(char ch) { |
|
161 return (ch==' ' || ch=='=' || ch=='\t'); |
|
162 } |
178 |
163 |
179 static const ObeyFileKeyword iKeywords[]; |
164 static const ObeyFileKeyword iKeywords[]; |
180 static const FileAttributeKeyword iAttributeKeywords[]; |
165 static const FileAttributeKeyword iAttributeKeywords[]; |
181 static TInt64 iTimeNow; |
166 static TInt64 iTimeNow; |
182 |
167 |
183 private: |
168 private: |
184 FILE* iObeyFile; |
169 TInt iCurrentLine; |
185 long iMark; |
170 StringVector iLines ; |
186 TInt iMarkLine; |
171 string iFileName; |
187 long iCurrentMark; |
172 TInt iNumWords; |
188 TInt iCurrentLine; |
173 char* iLine; |
189 TInt imaxLength; |
174 TInt iMarkLine ; |
190 TText* iFileName; |
175 char* iCurrentObeyStatement; |
191 TInt iNumWords; |
176 char iSuffix[80]; |
192 TText* iWord[KNumWords]; |
177 char* iWord[KNumWords]; |
193 TText* iSuffix; |
|
194 TText* iLine; |
|
195 TText* iCurrentObeyStatement; |
|
196 }; |
178 }; |
197 |
179 |
198 class CPatchDataProcessor; |
180 class CPatchDataProcessor; |
199 struct ConfigurableFatAttributes; |
181 struct ConfigurableFatAttributes; |
200 |
182 |
201 class CObeyFile |
183 class CObeyFile |
202 { |
184 { |
203 public: |
185 public: |
204 TText *iRomFileName; |
186 char* iRomFileName; |
205 TText *iExtensionRofsName; |
187 char* iExtensionRofsName; |
206 TText *iKernelRofsName; |
188 char* iKernelRofsName; |
207 TInt iRomSize; |
189 TInt iRomSize; |
208 TVersion iVersion; |
190 TVersion iVersion; |
209 TUint32 iCheckSum; |
191 TUint32 iCheckSum; |
210 TInt iNumberOfFiles; |
192 TInt iNumberOfFiles; |
211 TInt64 iTime; |
193 TInt64 iTime; |
212 TRomNode* iRootDirectory; |
194 TRomNode* iRootDirectory; |
213 TInt iNumberOfDataFiles; |
195 TInt iNumberOfDataFiles; |
214 // Added to support Data Drive Images. |
196 // Added to support Data Drive Images. |
215 TText* iDriveFileName; |
197 char* iDriveFileName; |
216 TInt64 iDataSize; |
198 TInt64 iDataSize; |
217 TText* iDriveFileFormat; |
199 char* iDriveFileFormat; |
218 ConfigurableFatAttributes* iConfigurableFatAttributes; |
200 ConfigurableFatAttributes* iConfigurableFatAttributes; |
219 |
201 |
220 private: |
202 private: |
221 ObeyFileReader& iReader; |
203 ObeyFileReader& iReader; |
222 TInt iMissingFiles; |
204 TInt iMissingFiles; |
234 TInt ProcessRofs(); |
216 TInt ProcessRofs(); |
235 TInt ProcessExtensionRofs(MRofsImage* info); |
217 TInt ProcessExtensionRofs(MRofsImage* info); |
236 TInt ProcessDataDrive(); // Process the data drive obey file. |
218 TInt ProcessDataDrive(); // Process the data drive obey file. |
237 TRomBuilderEntry *FirstFile(); |
219 TRomBuilderEntry *FirstFile(); |
238 TRomBuilderEntry *NextFile(); |
220 TRomBuilderEntry *NextFile(); |
239 TText* ProcessCoreImage(); |
221 char* ProcessCoreImage() const; |
240 void SkipToExtension(); |
222 void SkipToExtension(); |
241 TBool AutoSize(); |
223 TBool AutoSize() const {return iAutoSize ;} |
242 TUint32 AutoPageSize(); |
224 TUint32 AutoPageSize() const {return iAutoPageSize;} |
243 TBool Process(); |
225 TBool Process(); |
244 StringVector getValues(const String& aKey); |
226 |
|
227 StringVector getValues(const string& aKey); |
245 |
228 |
246 private: |
229 private: |
247 TBool ProcessFile(TInt aAlign, enum EKeyword aKeyword); |
230 TBool ProcessFile(TInt aAlign, enum EKeyword aKeyword); |
248 TBool ProcessDriveFile(enum EKeyword aKeyword); |
231 TBool ProcessDriveFile(enum EKeyword aKeyword); |
249 TBool ProcessRenaming(enum EKeyword aKeyword); |
232 TBool ProcessRenaming(enum EKeyword aKeyword); |
254 TInt ParseSection(); |
237 TInt ParseSection(); |
255 TBool ParsePatchDllData(); |
238 TBool ParsePatchDllData(); |
256 TBool GotKeyVariables(); |
239 TBool GotKeyVariables(); |
257 TBool GotKeyDriveVariables(); // To check the data drive mandatory variables. |
240 TBool GotKeyDriveVariables(); // To check the data drive mandatory variables. |
258 TBool GotExtensionVariables(MRofsImage* aRom); |
241 TBool GotExtensionVariables(MRofsImage* aRom); |
259 TBool GetNextBitOfFileName(TText **epocEndPtr); |
|
260 TText *IsValidFilePath(TText *aPath); |
|
261 void AddFile(TRomBuilderEntry* aFile); |
242 void AddFile(TRomBuilderEntry* aFile); |
262 |
243 |
263 TInt SetStackSize(TRomNode* aNode, TText *aStr); |
244 TInt SetStackSize(TRomNode* aNode, const char *aStr); |
264 TInt SetHeapSizeMin(TRomNode* aNode, TText *aStr); |
245 TInt SetHeapSizeMin(TRomNode* aNode, const char *aStr); |
265 TInt SetHeapSizeMax(TRomNode* aNode, TText *aStr); |
246 TInt SetHeapSizeMax(TRomNode* aNode, const char *aStr); |
266 TInt SetCapability(TRomNode* aNode, TText *aStr); |
247 TInt SetCapability(TRomNode* aNode, const char *aStr); |
267 TInt SetUid1(TRomNode* aNode, TText *aStr); |
248 TInt SetUid1(TRomNode* aNode, const char *aStr); |
268 TInt SetUid2(TRomNode* aNode, TText *aStr); |
249 TInt SetUid2(TRomNode* aNode, const char *aStr); |
269 TInt SetUid3(TRomNode* aNode, TText *aStr); |
250 TInt SetUid3(TRomNode* aNode, const char *aStr); |
270 TInt SetPriority(TRomNode* aNode, TText *aStr); |
251 TInt SetPriority(TRomNode* aNode, const char *aStr); |
|
252 |
|
253 static TBool GetNextBitOfFileName(char*& epocEndPtr); |
|
254 static const char *IsValidFilePath(const char *aPath); |
271 |
255 |
272 TBool iAutoSize; |
256 TBool iAutoSize; |
273 TUint32 iAutoPageSize; |
257 TUint32 iAutoPageSize; |
274 TBool iPagingOverrideParsed; |
258 TBool iPagingOverrideParsed; |
275 TBool iCodePagingOverrideParsed; |
259 TBool iCodePagingOverrideParsed; |
276 TBool iDataPagingOverrideParsed; |
260 TBool iDataPagingOverrideParsed; |
277 |
|
278 public: |
261 public: |
279 CPatchDataProcessor* iPatchData; |
262 CPatchDataProcessor* iPatchData; |
280 void SplitPatchDataStatement(StringVector& aPatchDataTokens); |
263 void SplitPatchDataStatement(StringVector& aPatchDataTokens); |
281 }; |
264 }; |
282 |
265 |