Update contrib.
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
25 #else //!__MSVCDOTNET__
27 #endif //__MSVCDOTNET__
32 ObyFile::ObyFile(const char* aObyFile)
37 file.open(aObyFile, ios::binary);
38 #else //!__MSVCDOTNET__
39 file.open(aObyFile, ios::nocreate | ios::binary);
40 #endif //__MSVCDOTNET__
43 cerr << "Unable to open OBY file '" << aObyFile << '\'' << endl;
47 file.seekg(0, ios::end);
48 iLength = file.tellg();
50 iText = new char[iLength+1];
51 file.seekg(0, ios::beg);
52 file.read(iText, iLength);
53 iText[iLength] = '\0';
56 for(char *p = iText;p < iText + iLength;p++) *p = tolower(*p);
64 void ObyFile::Parse(NonXIP* aNonXIP) const
66 // char* text = strstr(iText, "files=");
67 // if (text == 0) return;
69 const char* end = iText + iLength;
70 for(char* endl = strchr(text, '\r');text < end; text = endl + 2, endl = strchr(text, '\r'))
75 for(;isspace(*text);text++);
77 if (!strncmp(text, "primary", 7)) offset = 7;
78 else if (!strncmp(text, "secondary", 9)) offset = 9;
79 else if (!strncmp(text, "extension", 9)) offset = 9;
80 else if (!strncmp(text, "variant", 7)) offset = 7;
81 else if (!strncmp(text, "device", 6)) offset = 6;
82 else if (!strncmp(text, "file", 4)) offset = 4;
83 else if (!strncmp(text, "data", 4)) offset = 4;
84 else if (!strncmp(text, "dll", 3)) offset = 3;
86 if (offset == 0) continue;
91 text = strchr(text, ']');
92 if (text == 0) continue;
95 if (!(*text == '=' || *text == ' ' || *text == '\t')) continue;
98 for(;isspace(*text);text++);
99 char* orig_name = text;
100 if (*orig_name == '\"')
101 for(text = ++orig_name;*text && *text != '\"';text++);
103 for(;*text && !isspace(*text);text++);
104 if (*text == '\0') continue;
107 while(isspace(*++text));
108 char* seg_name = text;
109 if (*seg_name == '\"')
110 for(text = ++seg_name;*text && *text != '\"';text++);
112 for(;*text && !isspace(*text);text++);
114 if (*seg_name == '\0') continue;
116 aNonXIP->AddObyNames(*seg_name == '\\' ? ++seg_name : seg_name, *orig_name == '\\' ? ++orig_name : orig_name);