OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 #include "install-ds.h" | 5 #include "install-ds.h" |
6 #include <prmem.h> | 6 #include <prmem.h> |
7 #include <plstr.h> | 7 #include <plstr.h> |
8 #include <prprf.h> | 8 #include <prprf.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 #define FILE_PERMISSIONS_STRING "FilePermissions" | 22 #define FILE_PERMISSIONS_STRING "FilePermissions" |
23 #define EQUIVALENT_PLATFORM_STRING "EquivalentPlatform" | 23 #define EQUIVALENT_PLATFORM_STRING "EquivalentPlatform" |
24 #define EXECUTABLE_STRING "Executable" | 24 #define EXECUTABLE_STRING "Executable" |
25 | 25 |
26 #define DEFAULT_PERMISSIONS 0777 | 26 #define DEFAULT_PERMISSIONS 0777 |
27 | 27 |
28 #define PLATFORM_SEPARATOR_CHAR ':' | 28 #define PLATFORM_SEPARATOR_CHAR ':' |
29 | 29 |
30 /* Error codes */ | 30 /* Error codes */ |
31 enum { | 31 enum { |
32 » BOGUS_RELATIVE_DIR=0, | 32 BOGUS_RELATIVE_DIR = 0, |
33 » BOGUS_ABSOLUTE_DIR, | 33 BOGUS_ABSOLUTE_DIR, |
34 » BOGUS_FILE_PERMISSIONS, | 34 BOGUS_FILE_PERMISSIONS, |
35 » NO_RELATIVE_DIR, | 35 NO_RELATIVE_DIR, |
36 » NO_ABSOLUTE_DIR, | 36 NO_ABSOLUTE_DIR, |
37 » EMPTY_PLATFORM_STRING, | 37 EMPTY_PLATFORM_STRING, |
38 » BOGUS_PLATFORM_STRING, | 38 BOGUS_PLATFORM_STRING, |
39 » REPEAT_MODULE_FILE, | 39 REPEAT_MODULE_FILE, |
40 » REPEAT_MODULE_NAME, | 40 REPEAT_MODULE_NAME, |
41 » BOGUS_MODULE_FILE, | 41 BOGUS_MODULE_FILE, |
42 » BOGUS_MODULE_NAME, | 42 BOGUS_MODULE_NAME, |
43 » REPEAT_MECH, | 43 REPEAT_MECH, |
44 » BOGUS_MECH_FLAGS, | 44 BOGUS_MECH_FLAGS, |
45 » REPEAT_CIPHER, | 45 REPEAT_CIPHER, |
46 » BOGUS_CIPHER_FLAGS, | 46 BOGUS_CIPHER_FLAGS, |
47 » REPEAT_FILES, | 47 REPEAT_FILES, |
48 » REPEAT_EQUIV, | 48 REPEAT_EQUIV, |
49 » BOGUS_EQUIV, | 49 BOGUS_EQUIV, |
50 » EQUIV_TOO_MUCH_INFO, | 50 EQUIV_TOO_MUCH_INFO, |
51 » NO_FILES, | 51 NO_FILES, |
52 » NO_MODULE_FILE, | 52 NO_MODULE_FILE, |
53 » NO_MODULE_NAME, | 53 NO_MODULE_NAME, |
54 » NO_PLATFORMS, | 54 NO_PLATFORMS, |
55 » EQUIV_LOOP, | 55 EQUIV_LOOP, |
56 » UNKNOWN_MODULE_FILE | 56 UNKNOWN_MODULE_FILE |
57 }; | 57 }; |
58 | 58 |
59 /* Indexed by the above error codes */ | 59 /* Indexed by the above error codes */ |
60 static const char *errString[] = { | 60 static const char *errString[] = { |
61 » "%s: Invalid relative directory", | 61 "%s: Invalid relative directory", "%s: Invalid absolute directory", |
62 » "%s: Invalid absolute directory", | 62 "%s: Invalid file permissions", "%s: No relative directory specified", |
63 » "%s: Invalid file permissions", | 63 "%s: No absolute directory specified", |
64 » "%s: No relative directory specified", | 64 "Empty string given for platform name", "%s: invalid platform string", |
65 » "%s: No absolute directory specified", | 65 "More than one ModuleFile entry given for platform %s", |
66 » "Empty string given for platform name", | 66 "More than one ModuleName entry given for platform %s", |
67 » "%s: invalid platform string", | 67 "Invalid ModuleFile specification for platform %s", |
68 » "More than one ModuleFile entry given for platform %s", | 68 "Invalid ModuleName specification for platform %s", |
69 » "More than one ModuleName entry given for platform %s", | 69 "More than one DefaultMechanismFlags entry given for platform %s", |
70 » "Invalid ModuleFile specification for platform %s", | 70 "Invalid DefaultMechanismFlags specification for platform %s", |
71 » "Invalid ModuleName specification for platform %s", | 71 "More than one DefaultCipherFlags entry given for platform %s", |
72 » "More than one DefaultMechanismFlags entry given for platform %s", | 72 "Invalid DefaultCipherFlags entry given for platform %s", |
73 » "Invalid DefaultMechanismFlags specification for platform %s", | 73 "More than one Files entry given for platform %s", |
74 » "More than one DefaultCipherFlags entry given for platform %s", | 74 "More than one EquivalentPlatform entry given for platform %s", |
75 » "Invalid DefaultCipherFlags entry given for platform %s", | 75 "Invalid EquivalentPlatform specification for platform %s", |
76 » "More than one Files entry given for platform %s", | 76 "Module %s uses an EquivalentPlatform but also specifies its own" |
77 » "More than one EquivalentPlatform entry given for platform %s", | 77 " information", |
78 » "Invalid EquivalentPlatform specification for platform %s", | 78 "No Files specification in module %s", |
79 » "Module %s uses an EquivalentPlatform but also specifies its own" | 79 "No ModuleFile specification in module %s", |
80 » » " information", | 80 "No ModuleName specification in module %s", |
81 » "No Files specification in module %s", | 81 "No Platforms specification in installer script", |
82 » "No ModuleFile specification in module %s", | 82 "Platform %s has an equivalency loop", |
83 » "No ModuleName specification in module %s", | 83 "Module file \"%s\" in platform \"%s\" does not exist"}; |
84 » "No Platforms specification in installer script", | 84 |
85 » "Platform %s has an equivalency loop", | 85 static char *PR_Strdup(const char *str); |
86 » "Module file \"%s\" in platform \"%s\" does not exist" | 86 |
87 }; | 87 #define PAD(x) \ |
88 | 88 { \ |
89 static char* PR_Strdup(const char* str); | 89 int i; \ |
90 | 90 for (i = 0; i < x; i++) printf(" "); \ |
91 #define PAD(x) {int i; for(i=0;i<x;i++) printf(" ");} | 91 } |
92 #define PADINC 4 | 92 #define PADINC 4 |
93 | 93 |
94 Pk11Install_File* | 94 Pk11Install_File *Pk11Install_File_new() { |
95 Pk11Install_File_new() | 95 Pk11Install_File *new_this; |
96 { | 96 new_this = (Pk11Install_File *)PR_Malloc(sizeof(Pk11Install_File)); |
97 » Pk11Install_File* new_this; | 97 Pk11Install_File_init(new_this); |
98 » new_this = (Pk11Install_File*)PR_Malloc(sizeof(Pk11Install_File)); | 98 return new_this; |
99 » Pk11Install_File_init(new_this); | 99 } |
100 » return new_this; | 100 |
101 } | 101 void Pk11Install_File_init(Pk11Install_File *_this) { |
102 | 102 _this->jarPath = NULL; |
103 void | 103 _this->relativePath = NULL; |
104 Pk11Install_File_init(Pk11Install_File* _this) | 104 _this->absolutePath = NULL; |
105 { | 105 _this->executable = PR_FALSE; |
106 » _this->jarPath=NULL; | 106 _this->permissions = 0; |
107 » _this->relativePath=NULL; | |
108 » _this->absolutePath=NULL; | |
109 » _this->executable=PR_FALSE; | |
110 » _this->permissions=0; | |
111 } | 107 } |
112 | 108 |
113 /* | 109 /* |
114 ////////////////////////////////////////////////////////////////////////// | 110 ////////////////////////////////////////////////////////////////////////// |
115 // Method: ~Pk11Install_File | 111 // Method: ~Pk11Install_File |
116 // Class: Pk11Install_File | 112 // Class: Pk11Install_File |
117 // Notes: Destructor. | 113 // Notes: Destructor. |
118 */ | 114 */ |
119 void | 115 void Pk11Install_File_delete(Pk11Install_File *_this) { |
120 Pk11Install_File_delete(Pk11Install_File* _this) | 116 Pk11Install_File_Cleanup(_this); |
121 { | |
122 » Pk11Install_File_Cleanup(_this); | |
123 } | 117 } |
124 | 118 |
125 /* | 119 /* |
126 ////////////////////////////////////////////////////////////////////////// | 120 ////////////////////////////////////////////////////////////////////////// |
127 // Method: Cleanup | 121 // Method: Cleanup |
128 // Class: Pk11Install_File | 122 // Class: Pk11Install_File |
129 */ | 123 */ |
130 void | 124 void Pk11Install_File_Cleanup(Pk11Install_File *_this) { |
131 Pk11Install_File_Cleanup(Pk11Install_File* _this) | 125 if (_this->jarPath) { |
132 { | 126 PR_Free(_this->jarPath); |
133 » if(_this->jarPath) { | 127 _this->jarPath = NULL; |
134 » » PR_Free(_this->jarPath); | 128 } |
135 » » _this->jarPath = NULL; | 129 if (_this->relativePath) { |
136 » } | 130 PR_Free(_this->relativePath); |
137 » if(_this->relativePath) { | 131 _this->relativePath = NULL; |
138 » » PR_Free(_this->relativePath); | 132 } |
139 » » _this->relativePath = NULL; | 133 if (_this->absolutePath) { |
140 » } | 134 PR_Free(_this->absolutePath); |
141 » if(_this->absolutePath) { | 135 _this->absolutePath = NULL; |
142 » » PR_Free(_this->absolutePath); | 136 } |
143 » » _this->absolutePath = NULL; | 137 |
144 » } | 138 _this->permissions = 0; |
145 | 139 _this->executable = PR_FALSE; |
146 » _this->permissions = 0; | |
147 » _this->executable = PR_FALSE; | |
148 } | 140 } |
149 | 141 |
150 /* | 142 /* |
151 ////////////////////////////////////////////////////////////////////////// | 143 ////////////////////////////////////////////////////////////////////////// |
152 // Method: Generate | 144 // Method: Generate |
153 // Class: Pk11Install_File | 145 // Class: Pk11Install_File |
154 // Notes: Creates a file data structure from a syntax tree. | 146 // Notes: Creates a file data structure from a syntax tree. |
155 // Returns: NULL for success, otherwise an error message. | 147 // Returns: NULL for success, otherwise an error message. |
156 */ | 148 */ |
157 char* | 149 char *Pk11Install_File_Generate(Pk11Install_File *_this, |
158 Pk11Install_File_Generate(Pk11Install_File* _this, | 150 const Pk11Install_Pair *pair) { |
159 const Pk11Install_Pair *pair) | 151 Pk11Install_ListIter *iter; |
160 { | 152 Pk11Install_Value *val; |
161 » Pk11Install_ListIter *iter; | 153 Pk11Install_Pair *subpair; |
162 » Pk11Install_Value *val; | 154 Pk11Install_ListIter *subiter; |
163 » Pk11Install_Pair *subpair; | 155 Pk11Install_Value *subval; |
164 » Pk11Install_ListIter *subiter; | 156 char *errStr; |
165 » Pk11Install_Value *subval; | 157 char *endp; |
166 » char* errStr; | 158 PRBool gotPerms; |
167 » char *endp; | 159 |
168 » PRBool gotPerms; | 160 iter = NULL; |
169 | 161 subiter = NULL; |
170 » iter=NULL; | 162 errStr = NULL; |
171 » subiter=NULL; | 163 gotPerms = PR_FALSE; |
172 » errStr=NULL; | 164 |
173 » gotPerms=PR_FALSE; | 165 /* Clear out old values */ |
174 | 166 Pk11Install_File_Cleanup(_this); |
175 » /* Clear out old values */ | 167 |
176 » Pk11Install_File_Cleanup(_this); | 168 _this->jarPath = PR_Strdup(pair->key); |
177 | 169 |
178 » _this->jarPath = PR_Strdup(pair->key); | 170 /* Go through all the pairs under this file heading */ |
179 | 171 iter = Pk11Install_ListIter_new(pair->list); |
180 » /* Go through all the pairs under this file heading */ | 172 for (; (val = iter->current); Pk11Install_ListIter_nextItem(iter)) { |
181 » iter = Pk11Install_ListIter_new(pair->list); | 173 if (val->type == PAIR_VALUE) { |
182 » for( ; (val = iter->current); Pk11Install_ListIter_nextItem(iter)) { | 174 subpair = val->pair; |
183 » » if(val->type == PAIR_VALUE) { | 175 |
184 » » » subpair = val->pair; | 176 /* Relative directory */ |
185 | 177 if (!PORT_Strcasecmp(subpair->key, RELATIVE_DIR_STRING)) { |
186 » » » /* Relative directory */ | 178 subiter = Pk11Install_ListIter_new(subpair->list); |
187 » » » if(!PORT_Strcasecmp(subpair->key, RELATIVE_DIR_STRING))
{ | 179 subval = subiter->current; |
188 » » » » subiter = Pk11Install_ListIter_new(subpair->list
); | 180 if (!subval || (subval->type != STRING_VALUE)) { |
189 » » » » subval = subiter->current; | 181 errStr = PR_smprintf(errString[BOGUS_RELATIVE_DIR], _this->jarPath); |
190 » » » » if(!subval || (subval->type != STRING_VALUE)){ | 182 goto loser; |
191 » » » » » errStr = PR_smprintf(errString[BOGUS_REL
ATIVE_DIR], | 183 } |
192 _this->jarPath); | 184 _this->relativePath = PR_Strdup(subval->string); |
193 » » » » » goto loser; | 185 Pk11Install_ListIter_delete(subiter); |
194 » » » » } | 186 subiter = NULL; |
195 » » » » _this->relativePath = PR_Strdup(subval->string); | 187 |
196 » » » » Pk11Install_ListIter_delete(subiter); | 188 /* Absolute directory */ |
197 » » » » subiter = NULL; | 189 } else if (!PORT_Strcasecmp(subpair->key, ABSOLUTE_DIR_STRING)) { |
198 | 190 subiter = Pk11Install_ListIter_new(subpair->list); |
199 » » » » /* Absolute directory */ | 191 subval = subiter->current; |
200 » » » } else if( !PORT_Strcasecmp(subpair->key, ABSOLUTE_DIR_S
TRING)) { | 192 if (!subval || (subval->type != STRING_VALUE)) { |
201 » » » » subiter = Pk11Install_ListIter_new(subpair->list
); | 193 errStr = PR_smprintf(errString[BOGUS_ABSOLUTE_DIR], _this->jarPath); |
202 » » » » subval = subiter->current; | 194 goto loser; |
203 » » » » if(!subval || (subval->type != STRING_VALUE)){ | 195 } |
204 » » » » » errStr = PR_smprintf(errString[BOGUS_ABS
OLUTE_DIR], | 196 _this->absolutePath = PR_Strdup(subval->string); |
205 _this->jarPath); | 197 Pk11Install_ListIter_delete(subiter); |
206 » » » » » goto loser; | 198 subiter = NULL; |
207 » » » » } | 199 |
208 » » » » _this->absolutePath = PR_Strdup(subval->string); | 200 /* file permissions */ |
209 » » » » Pk11Install_ListIter_delete(subiter); | 201 } else if (!PORT_Strcasecmp(subpair->key, FILE_PERMISSIONS_STRING)) { |
210 » » » » subiter = NULL; | 202 subiter = Pk11Install_ListIter_new(subpair->list); |
211 | 203 subval = subiter->current; |
212 » » » /* file permissions */ | 204 if (!subval || (subval->type != STRING_VALUE) || !subval->string || |
213 » » » } else if( !PORT_Strcasecmp(subpair->key, | 205 !subval->string[0]) { |
214 FILE_PERMISSIONS_STRING)) { | 206 errStr = |
215 » » » » subiter = Pk11Install_ListIter_new(subpair->list
); | 207 PR_smprintf(errString[BOGUS_FILE_PERMISSIONS], _this->jarPath); |
216 » » » » subval = subiter->current; | 208 goto loser; |
217 » » » » if(!subval || (subval->type != STRING_VALUE) || | 209 } |
218 » » » » !subval->string || !subval->string[0]){ | 210 _this->permissions = (int)strtol(subval->string, &endp, 8); |
219 » » » » » errStr = PR_smprintf(errString[BOGUS_FIL
E_PERMISSIONS], | 211 if (*endp != '\0') { |
220 _this->jarPath); | 212 errStr = |
221 » » » » » goto loser; | 213 PR_smprintf(errString[BOGUS_FILE_PERMISSIONS], _this->jarPath); |
222 » » » » } | 214 goto loser; |
223 » » » » _this->permissions = (int) strtol(subval->string
, &endp, 8); | 215 } |
224 » » » » if(*endp != '\0') { | 216 gotPerms = PR_TRUE; |
225 » » » » » errStr = PR_smprintf(errString[BOGUS_FIL
E_PERMISSIONS], | 217 Pk11Install_ListIter_delete(subiter); |
226 _this->jarPath); | 218 subiter = NULL; |
227 » » » » » goto loser; | 219 } |
228 » » » » } | 220 } else { |
229 » » » » gotPerms = PR_TRUE; | 221 if (!PORT_Strcasecmp(val->string, EXECUTABLE_STRING)) { |
230 » » » » Pk11Install_ListIter_delete(subiter); | 222 _this->executable = PR_TRUE; |
231 » » » » subiter = NULL; | 223 } |
232 » » » } | 224 } |
233 » » } else { | 225 } |
234 » » » if(!PORT_Strcasecmp(val->string, EXECUTABLE_STRING)) { | 226 |
235 » » » » _this->executable = PR_TRUE; | 227 /* Default permission value */ |
236 » » » } | 228 if (!gotPerms) { |
237 » » } | 229 _this->permissions = DEFAULT_PERMISSIONS; |
238 » } | 230 } |
239 | 231 |
240 » /* Default permission value */ | 232 /* Make sure we got all the information */ |
241 » if(!gotPerms) { | 233 if (!_this->relativePath && !_this->absolutePath) { |
242 » » _this->permissions = DEFAULT_PERMISSIONS; | 234 errStr = PR_smprintf(errString[NO_ABSOLUTE_DIR], _this->jarPath); |
243 » } | 235 goto loser; |
244 | 236 } |
245 » /* Make sure we got all the information */ | |
246 » if(!_this->relativePath && !_this->absolutePath) { | |
247 » » errStr = PR_smprintf(errString[NO_ABSOLUTE_DIR], _this->jarPath)
; | |
248 » » goto loser; | |
249 » } | |
250 #if 0 | 237 #if 0 |
251 if(!_this->relativePath ) { | 238 if(!_this->relativePath ) { |
252 errStr = PR_smprintf(errString[NO_RELATIVE_DIR], _this->jarPath)
; | 239 errStr = PR_smprintf(errString[NO_RELATIVE_DIR], _this->jarPath)
; |
253 goto loser; | 240 goto loser; |
254 } | 241 } |
255 if(!_this->absolutePath) { | 242 if(!_this->absolutePath) { |
256 errStr = PR_smprintf(errString[NO_ABSOLUTE_DIR], _this->jarPath)
; | 243 errStr = PR_smprintf(errString[NO_ABSOLUTE_DIR], _this->jarPath)
; |
257 goto loser; | 244 goto loser; |
258 } | 245 } |
259 #endif | 246 #endif |
260 | 247 |
261 loser: | 248 loser: |
262 » if(iter) { | 249 if (iter) { |
263 » » Pk11Install_ListIter_delete(iter); | 250 Pk11Install_ListIter_delete(iter); |
264 » » PR_Free(iter); | 251 PR_Free(iter); |
265 » } | 252 } |
266 » if(subiter) { | 253 if (subiter) { |
267 » » Pk11Install_ListIter_delete(subiter); | 254 Pk11Install_ListIter_delete(subiter); |
268 » » PR_Free(subiter); | 255 PR_Free(subiter); |
269 » } | 256 } |
270 » return errStr; | 257 return errStr; |
271 } | 258 } |
272 | 259 |
273 /* | 260 /* |
274 ////////////////////////////////////////////////////////////////////////// | 261 ////////////////////////////////////////////////////////////////////////// |
275 // Method: Print | 262 // Method: Print |
276 // Class: Pk11Install_File | 263 // Class: Pk11Install_File |
277 */ | 264 */ |
278 void | 265 void Pk11Install_File_Print(Pk11Install_File *_this, int pad) { |
279 Pk11Install_File_Print(Pk11Install_File* _this, int pad) | 266 PAD(pad); |
280 { | 267 printf("jarPath: %s\n", _this->jarPath ? _this->jarPath : "<NULL>"); |
281 » PAD(pad); printf("jarPath: %s\n", | 268 PAD(pad); |
282 _this->jarPath ? _this->jarPath : "<NULL>"); | 269 printf("relativePath: %s\n", |
283 » PAD(pad); printf("relativePath: %s\n", | 270 _this->relativePath ? _this->relativePath : "<NULL>"); |
284 » » » » _this->relativePath ? _this->relativePath: "<NUL
L>"); | 271 PAD(pad); |
285 » PAD(pad); printf("absolutePath: %s\n", | 272 printf("absolutePath: %s\n", |
286 » » » » _this->absolutePath ? _this->absolutePath: "<NUL
L>"); | 273 _this->absolutePath ? _this->absolutePath : "<NULL>"); |
287 » PAD(pad); printf("permissions: %o\n", _this->permissions); | 274 PAD(pad); |
288 } | 275 printf("permissions: %o\n", _this->permissions); |
289 | 276 } |
290 Pk11Install_PlatformName* | 277 |
291 Pk11Install_PlatformName_new() | 278 Pk11Install_PlatformName *Pk11Install_PlatformName_new() { |
292 { | 279 Pk11Install_PlatformName *new_this; |
293 » Pk11Install_PlatformName* new_this; | 280 new_this = |
294 » new_this = (Pk11Install_PlatformName*) | 281 (Pk11Install_PlatformName *)PR_Malloc(sizeof(Pk11Install_PlatformName)); |
295 PR_Malloc(sizeof(Pk11Install_PlatformName)); | 282 Pk11Install_PlatformName_init(new_this); |
296 » Pk11Install_PlatformName_init(new_this); | 283 return new_this; |
297 » return new_this; | 284 } |
298 } | 285 |
299 | 286 void Pk11Install_PlatformName_init(Pk11Install_PlatformName *_this) { |
300 void | 287 _this->OS = NULL; |
301 Pk11Install_PlatformName_init(Pk11Install_PlatformName* _this) | 288 _this->verString = NULL; |
302 { | 289 _this->numDigits = 0; |
303 » _this->OS = NULL; | 290 _this->arch = NULL; |
304 » _this->verString = NULL; | |
305 » _this->numDigits = 0; | |
306 » _this->arch = NULL; | |
307 } | 291 } |
308 | 292 |
309 /* | 293 /* |
310 ////////////////////////////////////////////////////////////////////////// | 294 ////////////////////////////////////////////////////////////////////////// |
311 // Method: ~Pk11Install_PlatformName | 295 // Method: ~Pk11Install_PlatformName |
312 // Class: Pk11Install_PlatformName | 296 // Class: Pk11Install_PlatformName |
313 */ | 297 */ |
314 void | 298 void Pk11Install_PlatformName_delete(Pk11Install_PlatformName *_this) { |
315 Pk11Install_PlatformName_delete(Pk11Install_PlatformName* _this) | 299 Pk11Install_PlatformName_Cleanup(_this); |
316 { | |
317 » Pk11Install_PlatformName_Cleanup(_this); | |
318 } | 300 } |
319 | 301 |
320 /* | 302 /* |
321 ////////////////////////////////////////////////////////////////////////// | 303 ////////////////////////////////////////////////////////////////////////// |
322 // Method: Cleanup | 304 // Method: Cleanup |
323 // Class: Pk11Install_PlatformName | 305 // Class: Pk11Install_PlatformName |
324 */ | 306 */ |
325 void | 307 void Pk11Install_PlatformName_Cleanup(Pk11Install_PlatformName *_this) { |
326 Pk11Install_PlatformName_Cleanup(Pk11Install_PlatformName* _this) | 308 if (_this->OS) { |
327 { | 309 PR_Free(_this->OS); |
328 » if(_this->OS) { | 310 _this->OS = NULL; |
329 » » PR_Free(_this->OS); | 311 } |
330 » » _this->OS = NULL; | 312 if (_this->verString) { |
331 » } | 313 int i; |
332 » if(_this->verString) { | 314 for (i = 0; i < _this->numDigits; i++) { |
333 » » int i; | 315 PR_Free(_this->verString[i]); |
334 » » for (i=0; i<_this->numDigits; i++) { | 316 } |
335 » » » PR_Free(_this->verString[i]); | 317 PR_Free(_this->verString); |
336 » » } | 318 _this->verString = NULL; |
337 » » PR_Free(_this->verString); | 319 } |
338 » » _this->verString = NULL; | 320 if (_this->arch) { |
339 » } | 321 PR_Free(_this->arch); |
340 » if(_this->arch) { | 322 _this->arch = NULL; |
341 » » PR_Free(_this->arch); | 323 } |
342 » » _this->arch = NULL; | 324 _this->numDigits = 0; |
343 » } | |
344 » _this->numDigits = 0; | |
345 } | 325 } |
346 | 326 |
347 /* | 327 /* |
348 ////////////////////////////////////////////////////////////////////////// | 328 ////////////////////////////////////////////////////////////////////////// |
349 // Method: Generate | 329 // Method: Generate |
350 // Class: Pk11Install_PlatformName | 330 // Class: Pk11Install_PlatformName |
351 // Notes: Extracts the information from a platform string. | 331 // Notes: Extracts the information from a platform string. |
352 */ | 332 */ |
353 char* | 333 char *Pk11Install_PlatformName_Generate(Pk11Install_PlatformName *_this, |
354 Pk11Install_PlatformName_Generate(Pk11Install_PlatformName* _this, | 334 const char *str) { |
355 const char *str) | 335 char *errStr; |
356 { | 336 char *copy; |
357 » char *errStr; | 337 char *end, *start; /* start and end of a section (OS, version, arch)*/ |
358 » char *copy; | 338 char *pend, *pstart; /* start and end of one portion of version*/ |
359 » char *end, *start; /* start and end of a section (OS, version, arch)*/ | 339 char *endp; /* used by strtol*/ |
360 » char *pend, *pstart; /* start and end of one portion of version*/ | 340 int periods, i; |
361 » char *endp; /* used by strtol*/ | 341 |
362 » int periods, i; | 342 errStr = NULL; |
363 | 343 copy = NULL; |
364 » errStr=NULL; | 344 |
365 » copy=NULL; | 345 if (!str) { |
366 | 346 errStr = PR_smprintf(errString[EMPTY_PLATFORM_STRING]); |
367 » if(!str) { | 347 goto loser; |
368 » » errStr = PR_smprintf(errString[EMPTY_PLATFORM_STRING]); | 348 } |
369 » » goto loser; | 349 copy = PR_Strdup(str); |
370 » } | 350 |
371 » copy = PR_Strdup(str); | 351 /* |
372 | 352 // Get the OS |
373 » /* | 353 */ |
374 » // Get the OS | 354 end = strchr(copy, PLATFORM_SEPARATOR_CHAR); |
375 » */ | 355 if (!end || end == copy) { |
376 » end = strchr(copy, PLATFORM_SEPARATOR_CHAR); | 356 errStr = PR_smprintf(errString[BOGUS_PLATFORM_STRING], str); |
377 » if(!end || end==copy) { | 357 goto loser; |
378 » » errStr = PR_smprintf(errString[BOGUS_PLATFORM_STRING], str); | 358 } |
379 » » goto loser; | 359 *end = '\0'; |
380 » } | 360 |
381 » *end = '\0'; | 361 _this->OS = PR_Strdup(copy); |
382 | 362 |
383 » _this->OS = PR_Strdup(copy); | 363 /* |
384 | 364 // Get the digits of the version of form: x.x.x (arbitrary number of digits) |
385 » /* | 365 */ |
386 » // Get the digits of the version of form: x.x.x (arbitrary number of dig
its) | 366 |
387 » */ | 367 start = end + 1; |
388 | 368 end = strchr(start, PLATFORM_SEPARATOR_CHAR); |
389 » start = end+1; | 369 if (!end) { |
390 » end = strchr(start, PLATFORM_SEPARATOR_CHAR); | 370 errStr = PR_smprintf(errString[BOGUS_PLATFORM_STRING], str); |
391 » if(!end) { | 371 goto loser; |
392 » » errStr = PR_smprintf(errString[BOGUS_PLATFORM_STRING], str); | 372 } |
393 » » goto loser; | 373 *end = '\0'; |
394 » } | 374 |
395 » *end = '\0'; | 375 if (end != start) { |
396 | 376 /* Find out how many periods*/ |
397 » if(end!=start) {· | 377 periods = 0; |
398 » » /* Find out how many periods*/ | 378 pstart = start; |
399 » » periods = 0; | 379 while ((pend = strchr(pstart, '.'))) { |
400 » » pstart = start; | 380 periods++; |
401 » » while( (pend=strchr(pstart, '.')) ) { | 381 pstart = pend + 1; |
402 » » » periods++; | 382 } |
403 » » » pstart = pend+1; | 383 _this->numDigits = 1 + periods; |
404 » » } | 384 _this->verString = (char **)PR_Malloc(sizeof(char *) * _this->numDigits); |
405 » » _this->numDigits= 1+ periods; | 385 |
406 » » _this->verString = (char**)PR_Malloc(sizeof(char*)*_this->numDig
its); | 386 pstart = start; |
407 | 387 i = 0; |
408 » » pstart = start; | 388 /* Get the digits before each period*/ |
409 » » i = 0; | 389 while ((pend = strchr(pstart, '.'))) { |
410 » » /* Get the digits before each period*/ | 390 if (pend == pstart) { |
411 » » while( (pend=strchr(pstart, '.')) ) { | 391 errStr = PR_smprintf(errString[BOGUS_PLATFORM_STRING], str); |
412 » » » if(pend == pstart) { | 392 goto loser; |
413 » » » » errStr = PR_smprintf(errString[BOGUS_PLATFORM_ST
RING], str); | 393 } |
414 » » » » goto loser; | 394 *pend = '\0'; |
415 » » » } | 395 _this->verString[i] = PR_Strdup(pstart); |
416 » » » *pend = '\0'; | 396 endp = pend; |
417 » » » _this->verString[i] = PR_Strdup(pstart); | 397 if (endp == pstart || (*endp != '\0')) { |
418 » » » endp = pend; | 398 errStr = PR_smprintf(errString[BOGUS_PLATFORM_STRING], str); |
419 » » if(endp==pstart || (*endp != '\0')) { | 399 goto loser; |
420 » » » » errStr = PR_smprintf(errString[BOGUS_PLATFORM_ST
RING], str); | 400 } |
421 » » » » goto loser; | 401 pstart = pend + 1; |
422 » » » } | 402 i++; |
423 » » » pstart = pend+1; | 403 } |
424 » » » i++; | 404 /* Last digit comes after the last period*/ |
425 » » } | 405 if (*pstart == '\0') { |
426 » » /* Last digit comes after the last period*/ | 406 errStr = PR_smprintf(errString[BOGUS_PLATFORM_STRING], str); |
427 » » if(*pstart == '\0') { | 407 goto loser; |
428 » » » errStr = PR_smprintf(errString[BOGUS_PLATFORM_STRING], s
tr); | 408 } |
429 » » » goto loser; | 409 _this->verString[i] = PR_Strdup(pstart); |
430 » » } | 410 /* |
431 » » _this->verString[i] = PR_Strdup(pstart); | 411 if(endp==pstart || (*endp != '\0')) { |
432 » » /* | 412 errStr = PR_smprintf(errString[BOGUS_PLATFORM_STRING], str); |
433 » » if(endp==pstart || (*endp != '\0')) { | 413 goto loser; |
434 » » » errStr = PR_smprintf(errString[BOGUS_PLATFORM_STRING], s
tr); | 414 } |
435 » » » goto loser; | 415 */ |
436 » » } | 416 } else { |
437 » » */ | 417 _this->verString = NULL; |
438 » } else { | 418 _this->numDigits = 0; |
439 » » _this->verString = NULL; | 419 } |
440 » » _this->numDigits = 0; | 420 |
441 » } | 421 /* |
442 | 422 // Get the architecture |
443 » /* | 423 */ |
444 » // Get the architecture | 424 start = end + 1; |
445 » */ | 425 if (strchr(start, PLATFORM_SEPARATOR_CHAR)) { |
446 » start = end+1; | 426 errStr = PR_smprintf(errString[BOGUS_PLATFORM_STRING], str); |
447 » if( strchr(start, PLATFORM_SEPARATOR_CHAR) ) { | 427 goto loser; |
448 » » errStr = PR_smprintf(errString[BOGUS_PLATFORM_STRING], str); | 428 } |
449 » » goto loser; | 429 _this->arch = PR_Strdup(start); |
450 » } | 430 |
451 » _this->arch = PR_Strdup(start); | 431 if (copy) { |
452 | 432 PR_Free(copy); |
453 » if(copy) { | 433 } |
454 » » PR_Free(copy); | 434 return NULL; |
455 » } | |
456 » return NULL; | |
457 loser: | 435 loser: |
458 » if(_this->OS) { | 436 if (_this->OS) { |
459 » » PR_Free(_this->OS); | 437 PR_Free(_this->OS); |
460 » » _this->OS = NULL; | 438 _this->OS = NULL; |
461 » } | 439 } |
462 » if(_this->verString) { | 440 if (_this->verString) { |
463 » » for (i=0; i<_this->numDigits; i++) { | 441 for (i = 0; i < _this->numDigits; i++) { |
464 » » » PR_Free(_this->verString[i]); | 442 PR_Free(_this->verString[i]); |
465 » » } | 443 } |
466 » » PR_Free(_this->verString); | 444 PR_Free(_this->verString); |
467 » » _this->verString = NULL; | 445 _this->verString = NULL; |
468 » } | 446 } |
469 » _this->numDigits = 0; | 447 _this->numDigits = 0; |
470 » if(_this->arch) { | 448 if (_this->arch) { |
471 » » PR_Free(_this->arch); | 449 PR_Free(_this->arch); |
472 » » _this->arch = NULL; | 450 _this->arch = NULL; |
473 » } | 451 } |
474 | 452 |
475 » return errStr; | 453 return errStr; |
476 } | 454 } |
477 | 455 |
478 /* | 456 /* |
479 ////////////////////////////////////////////////////////////////////////// | 457 ////////////////////////////////////////////////////////////////////////// |
480 // Method: operator == | 458 // Method: operator == |
481 // Class: Pk11Install_PlatformName | 459 // Class: Pk11Install_PlatformName |
482 // Returns: PR_TRUE if the platform have the same OS, arch, and version | 460 // Returns: PR_TRUE if the platform have the same OS, arch, and version |
483 */ | 461 */ |
484 PRBool | 462 PRBool Pk11Install_PlatformName_equal(Pk11Install_PlatformName *_this, |
485 Pk11Install_PlatformName_equal(Pk11Install_PlatformName* _this, | 463 Pk11Install_PlatformName *cmp) { |
486 Pk11Install_PlatformName* cmp)· | 464 int i; |
487 { | 465 |
488 » int i; | 466 if (!_this->OS || !_this->arch || !cmp->OS || !cmp->arch) { |
489 | 467 return PR_FALSE; |
490 » if(!_this->OS || !_this->arch || !cmp->OS || !cmp->arch) { | 468 } |
491 » » return PR_FALSE; | 469 |
492 » } | 470 if (PORT_Strcasecmp(_this->OS, cmp->OS) || |
493 | 471 PORT_Strcasecmp(_this->arch, cmp->arch) || |
494 » if(» PORT_Strcasecmp(_this->OS, cmp->OS) || | 472 _this->numDigits != cmp->numDigits) { |
495 » » PORT_Strcasecmp(_this->arch, cmp->arch) || | 473 return PR_FALSE; |
496 » » _this->numDigits != cmp->numDigits ) { | 474 } |
497 » » » return PR_FALSE; | 475 |
498 » } | 476 for (i = 0; i < _this->numDigits; i++) { |
499 | 477 if (PORT_Strcasecmp(_this->verString[i], cmp->verString[i])) { |
500 » for(i=0; i < _this->numDigits; i++) { | 478 return PR_FALSE; |
501 » » if(PORT_Strcasecmp(_this->verString[i], cmp->verString[i])) { | 479 } |
502 » » » return PR_FALSE; | 480 } |
503 » » } | 481 return PR_TRUE; |
504 » } | |
505 » return PR_TRUE; | |
506 } | 482 } |
507 | 483 |
508 /* | 484 /* |
509 ////////////////////////////////////////////////////////////////////////// | 485 ////////////////////////////////////////////////////////////////////////// |
510 // Method: operator <= | 486 // Method: operator <= |
511 // Class: Pk11Install_PlatformName | 487 // Class: Pk11Install_PlatformName |
512 // Returns: PR_TRUE if the platform have the same OS and arch and a lower | 488 // Returns: PR_TRUE if the platform have the same OS and arch and a lower |
513 // or equal release. | 489 // or equal release. |
514 */ | 490 */ |
515 PRBool | 491 PRBool Pk11Install_PlatformName_lteq(Pk11Install_PlatformName *_this, |
516 Pk11Install_PlatformName_lteq(Pk11Install_PlatformName* _this, | 492 Pk11Install_PlatformName *cmp) { |
517 Pk11Install_PlatformName* cmp) | 493 return (Pk11Install_PlatformName_equal(_this, cmp) || |
518 { | 494 Pk11Install_PlatformName_lt(_this, cmp)) |
519 » return (Pk11Install_PlatformName_equal(_this,cmp) || | 495 ? PR_TRUE |
520 Pk11Install_PlatformName_lt(_this,cmp)) ? PR_TRUE : PR_FALSE; | 496 : PR_FALSE; |
521 } | 497 } |
522 | 498 |
523 /* | 499 /* |
524 ////////////////////////////////////////////////////////////////////////// | 500 ////////////////////////////////////////////////////////////////////////// |
525 // Method: operator < | 501 // Method: operator < |
526 // Class: Pk11Install_PlatformName | 502 // Class: Pk11Install_PlatformName |
527 // Returns: PR_TRUE if the platform have the same OS and arch and a greater | 503 // Returns: PR_TRUE if the platform have the same OS and arch and a greater |
528 // release. | 504 // release. |
529 */ | 505 */ |
530 PRBool | 506 PRBool Pk11Install_PlatformName_lt(Pk11Install_PlatformName *_this, |
531 Pk11Install_PlatformName_lt(Pk11Install_PlatformName* _this, | 507 Pk11Install_PlatformName *cmp) { |
532 Pk11Install_PlatformName* cmp) | 508 int i, scmp; |
533 { | 509 |
534 » int i, scmp; | 510 if (!_this->OS || !_this->arch || !cmp->OS || !cmp->arch) { |
535 | 511 return PR_FALSE; |
536 » if(!_this->OS || !_this->arch || !cmp->OS || !cmp->arch) { | 512 } |
537 » » return PR_FALSE; | 513 |
538 » } | 514 if (PORT_Strcasecmp(_this->OS, cmp->OS)) { |
539 | 515 return PR_FALSE; |
540 » if( PORT_Strcasecmp(_this->OS, cmp->OS) ) { | 516 } |
541 » » return PR_FALSE; | 517 if (PORT_Strcasecmp(_this->arch, cmp->arch)) { |
542 » } | 518 return PR_FALSE; |
543 » if( PORT_Strcasecmp(_this->arch, cmp->arch) ) { | 519 } |
544 » » return PR_FALSE; | 520 |
545 » } | 521 for (i = 0; (i < _this->numDigits) && (i < cmp->numDigits); i++) { |
546 | 522 scmp = PORT_Strcasecmp(_this->verString[i], cmp->verString[i]); |
547 » for(i=0; (i < _this->numDigits) && (i < cmp->numDigits); i++) { | 523 if (scmp > 0) { |
548 » » scmp = PORT_Strcasecmp(_this->verString[i], cmp->verString[i]); | 524 return PR_FALSE; |
549 » » if (scmp > 0) { | 525 } else if (scmp < 0) { |
550 » » » return PR_FALSE; | 526 return PR_TRUE; |
551 » » } else if (scmp < 0) { | 527 } |
552 » » » return PR_TRUE; | 528 } |
553 » » } | 529 /* All the digits they have in common are the same. */ |
554 » } | 530 if (_this->numDigits < cmp->numDigits) { |
555 » /* All the digits they have in common are the same. */ | 531 return PR_TRUE; |
556 » if(_this->numDigits < cmp->numDigits) { | 532 } |
557 » » return PR_TRUE; | 533 |
558 » }· | 534 return PR_FALSE; |
559 | |
560 » return PR_FALSE; | |
561 } | 535 } |
562 | 536 |
563 /* | 537 /* |
564 ////////////////////////////////////////////////////////////////////////// | 538 ////////////////////////////////////////////////////////////////////////// |
565 // Method: GetString | 539 // Method: GetString |
566 // Class: Pk11Install_PlatformName | 540 // Class: Pk11Install_PlatformName |
567 // Returns: String composed of OS, release, and architecture separated | 541 // Returns: String composed of OS, release, and architecture separated |
568 //» » » by the separator char. Memory is allocated by this func
tion | 542 //» » » by the separator char. Memory is allocated by this |
| 543 function |
569 // but is the responsibility of the caller to de-allocate. | 544 // but is the responsibility of the caller to de-allocate. |
570 */ | 545 */ |
571 char* | 546 char *Pk11Install_PlatformName_GetString(Pk11Install_PlatformName *_this) { |
572 Pk11Install_PlatformName_GetString(Pk11Install_PlatformName* _this)· | 547 char *ret; |
573 { | 548 char *ver; |
574 » char *ret; | 549 char *OS_; |
575 » char *ver; | 550 char *arch_; |
576 » char *OS_; | 551 |
577 » char *arch_; | 552 OS_ = NULL; |
578 | 553 arch_ = NULL; |
579 » OS_=NULL; | 554 |
580 » arch_=NULL; | 555 OS_ = _this->OS ? _this->OS : ""; |
581 | 556 arch_ = _this->arch ? _this->arch : ""; |
582 » OS_ = _this->OS ? _this->OS : ""; | 557 |
583 » arch_ = _this->arch ? _this->arch : ""; | 558 ver = Pk11Install_PlatformName_GetVerString(_this); |
584 | 559 ret = PR_smprintf("%s%c%s%c%s", OS_, PLATFORM_SEPARATOR_CHAR, ver, |
585 » ver = Pk11Install_PlatformName_GetVerString(_this); | 560 PLATFORM_SEPARATOR_CHAR, arch_); |
586 » ret = PR_smprintf("%s%c%s%c%s", OS_, PLATFORM_SEPARATOR_CHAR, ver, | 561 |
587 » » » » » PLATFORM_SEPARATOR_CHAR, arch_); | 562 PR_Free(ver); |
588 | 563 |
589 » PR_Free(ver); | 564 return ret; |
590 | |
591 » return ret; | |
592 } | 565 } |
593 | 566 |
594 /* | 567 /* |
595 ////////////////////////////////////////////////////////////////////////// | 568 ////////////////////////////////////////////////////////////////////////// |
596 // Method: GetVerString | 569 // Method: GetVerString |
597 // Class: Pk11Install_PlatformName | 570 // Class: Pk11Install_PlatformName |
598 // Returns: The version string for this platform, in the form x.x.x with an | 571 // Returns: The version string for this platform, in the form x.x.x with an |
599 //» » » arbitrary number of digits. Memory allocated by functio
n, | 572 //» » » arbitrary number of digits. Memory allocated by |
| 573 function, |
600 // must be de-allocated by caller. | 574 // must be de-allocated by caller. |
601 */ | 575 */ |
602 char* | 576 char *Pk11Install_PlatformName_GetVerString(Pk11Install_PlatformName *_this) { |
603 Pk11Install_PlatformName_GetVerString(Pk11Install_PlatformName* _this)· | 577 char *tmp; |
604 { | 578 char *ret; |
605 » char *tmp; | 579 int i; |
606 » char *ret; | 580 char buf[80]; |
607 » int i; | 581 |
608 » char buf[80]; | 582 tmp = (char *)PR_Malloc(80 * _this->numDigits + 1); |
609 | 583 tmp[0] = '\0'; |
610 » tmp = (char*)PR_Malloc(80*_this->numDigits+1); | 584 |
611 » tmp[0] = '\0'; | 585 for (i = 0; i < _this->numDigits - 1; i++) { |
612 | 586 sprintf(buf, "%s.", _this->verString[i]); |
613 » for(i=0; i < _this->numDigits-1; i++) { | 587 strcat(tmp, buf); |
614 » » sprintf(buf, "%s.", _this->verString[i]); | 588 } |
615 » » strcat(tmp, buf); | 589 if (i < _this->numDigits) { |
616 » } | 590 sprintf(buf, "%s", _this->verString[i]); |
617 » if(i < _this->numDigits) { | 591 strcat(tmp, buf); |
618 » » sprintf(buf, "%s", _this->verString[i]); | 592 } |
619 » » strcat(tmp, buf); | 593 |
620 » } | 594 ret = PR_Strdup(tmp); |
621 | 595 free(tmp); |
622 » ret = PR_Strdup(tmp); | 596 |
623 » free(tmp); | 597 return ret; |
624 | |
625 » return ret; | |
626 } | 598 } |
627 | 599 |
628 /* | 600 /* |
629 ////////////////////////////////////////////////////////////////////////// | 601 ////////////////////////////////////////////////////////////////////////// |
630 // Method: Print | 602 // Method: Print |
631 // Class: Pk11Install_PlatformName | 603 // Class: Pk11Install_PlatformName |
632 */ | 604 */ |
633 void | 605 void Pk11Install_PlatformName_Print(Pk11Install_PlatformName *_this, int pad) { |
634 Pk11Install_PlatformName_Print(Pk11Install_PlatformName* _this, int pad) | 606 PAD(pad); |
635 { | 607 printf("OS: %s\n", _this->OS ? _this->OS : "<NULL>"); |
636 » PAD(pad); printf("OS: %s\n", _this->OS ? _this->OS : "<NULL>"); | 608 PAD(pad); |
637 » PAD(pad); printf("Digits: "); | 609 printf("Digits: "); |
638 » if(_this->numDigits == 0) { | 610 if (_this->numDigits == 0) { |
639 » » printf("None\n"); | 611 printf("None\n"); |
640 » } else { | 612 } else { |
641 » » printf("%s\n", Pk11Install_PlatformName_GetVerString(_this)); | 613 printf("%s\n", Pk11Install_PlatformName_GetVerString(_this)); |
642 » } | 614 } |
643 » PAD(pad); printf("arch: %s\n", _this->arch ? _this->arch : "<NULL>"); | 615 PAD(pad); |
644 } | 616 printf("arch: %s\n", _this->arch ? _this->arch : "<NULL>"); |
645 | 617 } |
646 Pk11Install_Platform* | 618 |
647 Pk11Install_Platform_new() | 619 Pk11Install_Platform *Pk11Install_Platform_new() { |
648 { | 620 Pk11Install_Platform *new_this; |
649 » Pk11Install_Platform* new_this; | 621 new_this = (Pk11Install_Platform *)PR_Malloc(sizeof(Pk11Install_Platform)); |
650 » new_this = (Pk11Install_Platform*)PR_Malloc(sizeof(Pk11Install_Platform)
); | 622 Pk11Install_Platform_init(new_this); |
651 » Pk11Install_Platform_init(new_this); | 623 return new_this; |
652 » return new_this; | 624 } |
653 } | 625 |
654 | 626 void Pk11Install_Platform_init(Pk11Install_Platform *_this) { |
655 void | 627 Pk11Install_PlatformName_init(&_this->name); |
656 Pk11Install_Platform_init(Pk11Install_Platform* _this) | 628 Pk11Install_PlatformName_init(&_this->equivName); |
657 { | 629 _this->equiv = NULL; |
658 » Pk11Install_PlatformName_init(&_this->name); | 630 _this->usesEquiv = PR_FALSE; |
659 » Pk11Install_PlatformName_init(&_this->equivName); | 631 _this->moduleFile = NULL; |
660 » _this->equiv = NULL; | 632 _this->moduleName = NULL; |
661 » _this->usesEquiv = PR_FALSE; | 633 _this->modFile = -1; |
662 » _this->moduleFile = NULL; | 634 _this->mechFlags = 0; |
663 » _this->moduleName = NULL; | 635 _this->cipherFlags = 0; |
664 » _this->modFile = -1; | 636 _this->files = NULL; |
665 » _this->mechFlags = 0; | 637 _this->numFiles = 0; |
666 » _this->cipherFlags = 0; | |
667 » _this->files = NULL; | |
668 » _this->numFiles = 0; | |
669 } | 638 } |
670 | 639 |
671 /* | 640 /* |
672 ////////////////////////////////////////////////////////////////////////// | 641 ////////////////////////////////////////////////////////////////////////// |
673 // Method: ~Pk11Install_Platform | 642 // Method: ~Pk11Install_Platform |
674 // Class: Pk11Install_Platform | 643 // Class: Pk11Install_Platform |
675 */ | 644 */ |
676 void | 645 void Pk11Install_Platform_delete(Pk11Install_Platform *_this) { |
677 Pk11Install_Platform_delete(Pk11Install_Platform* _this) | 646 Pk11Install_Platform_Cleanup(_this); |
678 { | |
679 » Pk11Install_Platform_Cleanup(_this); | |
680 } | 647 } |
681 | 648 |
682 /* | 649 /* |
683 ////////////////////////////////////////////////////////////////////////// | 650 ////////////////////////////////////////////////////////////////////////// |
684 // Method: Cleanup | 651 // Method: Cleanup |
685 // Class: Pk11Install_Platform | 652 // Class: Pk11Install_Platform |
686 */ | 653 */ |
687 void | 654 void Pk11Install_Platform_Cleanup(Pk11Install_Platform *_this) { |
688 Pk11Install_Platform_Cleanup(Pk11Install_Platform* _this) | 655 int i; |
689 { | 656 if (_this->moduleFile) { |
690 » int i; | 657 PR_Free(_this->moduleFile); |
691 » if(_this->moduleFile) { | 658 _this->moduleFile = NULL; |
692 » » PR_Free(_this->moduleFile); | 659 } |
693 » » _this->moduleFile = NULL; | 660 if (_this->moduleName) { |
694 » } | 661 PR_Free(_this->moduleName); |
695 » if(_this->moduleName) { | 662 _this->moduleName = NULL; |
696 » » PR_Free(_this->moduleName); | 663 } |
697 » » _this->moduleName = NULL; | 664 if (_this->files) { |
698 » } | 665 for (i = 0; i < _this->numFiles; i++) { |
699 » if(_this->files) { | 666 Pk11Install_File_delete(&_this->files[i]); |
700 » » for (i=0;i<_this->numFiles;i++) { | 667 } |
701 » » » Pk11Install_File_delete(&_this->files[i]); | 668 PR_Free(_this->files); |
702 » » } | 669 _this->files = NULL; |
703 » » PR_Free(_this->files); | 670 } |
704 » » _this->files = NULL; | 671 _this->equiv = NULL; |
705 » } | 672 _this->usesEquiv = PR_FALSE; |
706 » _this->equiv = NULL; | 673 _this->modFile = -1; |
707 » _this->usesEquiv = PR_FALSE; | 674 _this->numFiles = 0; |
708 » _this->modFile = -1; | 675 _this->mechFlags = _this->cipherFlags = 0; |
709 » _this->numFiles = 0; | |
710 » _this->mechFlags = _this->cipherFlags = 0; | |
711 } | 676 } |
712 | 677 |
713 /* | 678 /* |
714 ////////////////////////////////////////////////////////////////////////// | 679 ////////////////////////////////////////////////////////////////////////// |
715 // Method: Generate | 680 // Method: Generate |
716 // Class: Pk11Install_Platform | 681 // Class: Pk11Install_Platform |
717 // Notes: Creates a platform data structure from a syntax tree. | 682 // Notes: Creates a platform data structure from a syntax tree. |
718 // Returns: NULL for success, otherwise an error message. | 683 // Returns: NULL for success, otherwise an error message. |
719 */ | 684 */ |
720 char* | 685 char *Pk11Install_Platform_Generate(Pk11Install_Platform *_this, |
721 Pk11Install_Platform_Generate(Pk11Install_Platform* _this, | 686 const Pk11Install_Pair *pair) { |
722 const Pk11Install_Pair *pair) | 687 char *errStr; |
723 { | 688 char *endptr; |
724 char* errStr; | 689 char *tmp; |
725 char* endptr; | 690 int i; |
726 char* tmp; | 691 Pk11Install_ListIter *iter; |
727 int i; | 692 Pk11Install_Value *val; |
728 Pk11Install_ListIter *iter; | 693 Pk11Install_Value *subval; |
729 Pk11Install_Value *val; | 694 Pk11Install_Pair *subpair; |
730 Pk11Install_Value *subval; | 695 Pk11Install_ListIter *subiter; |
731 Pk11Install_Pair *subpair; | 696 PRBool gotModuleFile, gotModuleName, gotMech, gotCipher, gotFiles, gotEquiv; |
732 Pk11Install_ListIter *subiter; | 697 |
733 PRBool gotModuleFile, gotModuleName, gotMech,· | 698 errStr = NULL; |
734 gotCipher, gotFiles, gotEquiv; | 699 iter = subiter = NULL; |
735 | 700 val = subval = NULL; |
736 errStr=NULL; | 701 subpair = NULL; |
737 iter=subiter=NULL; | 702 gotModuleFile = gotModuleName = gotMech = gotCipher = gotFiles = gotEquiv = |
738 val=subval=NULL; | 703 PR_FALSE; |
739 subpair=NULL; | 704 Pk11Install_Platform_Cleanup(_this); |
740 gotModuleFile=gotModuleName=gotMech=gotCipher=gotFiles=gotEquiv=PR_FALSE
; | 705 |
741 Pk11Install_Platform_Cleanup(_this); | 706 errStr = Pk11Install_PlatformName_Generate(&_this->name, pair->key); |
742 | 707 if (errStr) { |
743 errStr = Pk11Install_PlatformName_Generate(&_this->name,pair->key); | 708 tmp = PR_smprintf("%s: %s", pair->key, errStr); |
744 if(errStr) { | 709 PR_smprintf_free(errStr); |
745 tmp = PR_smprintf("%s: %s", pair->key, errStr); | 710 errStr = tmp; |
746 PR_smprintf_free(errStr); | 711 goto loser; |
747 errStr = tmp; | 712 } |
748 goto loser; | 713 |
749 } | 714 iter = Pk11Install_ListIter_new(pair->list); |
750 | 715 for (; (val = iter->current); Pk11Install_ListIter_nextItem(iter)) { |
751 iter = Pk11Install_ListIter_new(pair->list); | 716 if (val->type == PAIR_VALUE) { |
752 for( ; (val=iter->current); Pk11Install_ListIter_nextItem(iter)) { | 717 subpair = val->pair; |
753 if(val->type==PAIR_VALUE) { | 718 |
754 subpair = val->pair; | 719 if (!PORT_Strcasecmp(subpair->key, MODULE_FILE_STRING)) { |
755 | 720 if (gotModuleFile) { |
756 if( !PORT_Strcasecmp(subpair->key, MODULE_FILE_STRING))
{ | 721 errStr = |
757 if(gotModuleFile) { | 722 PR_smprintf(errString[REPEAT_MODULE_FILE], |
758 errStr = PR_smprintf(errString[REPEAT_MO
DULE_FILE], | 723 Pk11Install_PlatformName_GetString(&_this->name)); |
759 Pk11Install_PlatformName_GetString(&_this->n
ame)); | 724 goto loser; |
760 goto loser; | 725 } |
761 } | 726 subiter = Pk11Install_ListIter_new(subpair->list); |
762 subiter = Pk11Install_ListIter_new(subpair->list
); | 727 subval = subiter->current; |
763 subval = subiter->current; | 728 if (!subval || (subval->type != STRING_VALUE)) { |
764 if(!subval || (subval->type != STRING_VALUE)) { | 729 errStr = |
765 errStr = PR_smprintf(errString[BOGUS_MOD
ULE_FILE], | 730 PR_smprintf(errString[BOGUS_MODULE_FILE], |
766 Pk11Install_PlatformName_GetString(&_this->n
ame)); | 731 Pk11Install_PlatformName_GetString(&_this->name)); |
767 goto loser; | 732 goto loser; |
768 } | 733 } |
769 _this->moduleFile = PR_Strdup(subval->string); | 734 _this->moduleFile = PR_Strdup(subval->string); |
770 Pk11Install_ListIter_delete(subiter); | 735 Pk11Install_ListIter_delete(subiter); |
771 PR_Free(subiter); | 736 PR_Free(subiter); |
772 subiter = NULL; | 737 subiter = NULL; |
773 gotModuleFile = PR_TRUE; | 738 gotModuleFile = PR_TRUE; |
774 } else if(!PORT_Strcasecmp(subpair->key, MODULE_NAME_STR
ING)){ | 739 } else if (!PORT_Strcasecmp(subpair->key, MODULE_NAME_STRING)) { |
775 if(gotModuleName) { | 740 if (gotModuleName) { |
776 errStr = PR_smprintf(errString[REPEAT_MO
DULE_NAME], | 741 errStr = |
777 Pk11Install_PlatformName_GetString(&_this->n
ame)); | 742 PR_smprintf(errString[REPEAT_MODULE_NAME], |
778 goto loser; | 743 Pk11Install_PlatformName_GetString(&_this->name)); |
779 } | 744 goto loser; |
780 subiter = Pk11Install_ListIter_new(subpair->list
); | 745 } |
781 subval = subiter->current; | 746 subiter = Pk11Install_ListIter_new(subpair->list); |
782 if(!subval || (subval->type != STRING_VALUE)) { | 747 subval = subiter->current; |
783 errStr = PR_smprintf(errString[BOGUS_MOD
ULE_NAME], | 748 if (!subval || (subval->type != STRING_VALUE)) { |
784 Pk11Install_PlatformName_GetString(&_this->n
ame)); | 749 errStr = |
785 goto loser; | 750 PR_smprintf(errString[BOGUS_MODULE_NAME], |
786 } | 751 Pk11Install_PlatformName_GetString(&_this->name)); |
787 _this->moduleName = PR_Strdup(subval->string); | 752 goto loser; |
788 Pk11Install_ListIter_delete(subiter); | 753 } |
789 PR_Free(subiter); | 754 _this->moduleName = PR_Strdup(subval->string); |
790 subiter = NULL; | 755 Pk11Install_ListIter_delete(subiter); |
791 gotModuleName = PR_TRUE; | 756 PR_Free(subiter); |
792 } else if(!PORT_Strcasecmp(subpair->key, MECH_FLAGS_STRI
NG)) { | 757 subiter = NULL; |
793 endptr=NULL; | 758 gotModuleName = PR_TRUE; |
794 | 759 } else if (!PORT_Strcasecmp(subpair->key, MECH_FLAGS_STRING)) { |
795 if(gotMech) { | 760 endptr = NULL; |
796 errStr = PR_smprintf(errString[REPEAT_ME
CH], | 761 |
797 Pk11Install_PlatformName_GetString(&_this->n
ame)); | 762 if (gotMech) { |
798 goto loser; | 763 errStr = |
799 } | 764 PR_smprintf(errString[REPEAT_MECH], |
800 subiter = Pk11Install_ListIter_new(subpair->list
); | 765 Pk11Install_PlatformName_GetString(&_this->name)); |
801 subval = subiter->current; | 766 goto loser; |
802 if(!subval || (subval->type != STRING_VALUE)) { | 767 } |
803 errStr = PR_smprintf(errString[BOGUS_MEC
H_FLAGS], | 768 subiter = Pk11Install_ListIter_new(subpair->list); |
804 Pk11Install_PlatformName_GetString(&_this->n
ame)); | 769 subval = subiter->current; |
805 goto loser; | 770 if (!subval || (subval->type != STRING_VALUE)) { |
806 } | 771 errStr = |
807 _this->mechFlags = strtol(subval->string, &endpt
r, 0); | 772 PR_smprintf(errString[BOGUS_MECH_FLAGS], |
808 if(*endptr!='\0' || (endptr==subval->string) ) { | 773 Pk11Install_PlatformName_GetString(&_this->name)); |
809 errStr = PR_smprintf(errString[BOGUS_MEC
H_FLAGS], | 774 goto loser; |
810 Pk11Install_PlatformName_GetString(&_this->n
ame)); | 775 } |
811 goto loser; | 776 _this->mechFlags = strtol(subval->string, &endptr, 0); |
812 } | 777 if (*endptr != '\0' || (endptr == subval->string)) { |
813 Pk11Install_ListIter_delete(subiter); | 778 errStr = |
814 PR_Free(subiter); | 779 PR_smprintf(errString[BOGUS_MECH_FLAGS], |
815 subiter=NULL; | 780 Pk11Install_PlatformName_GetString(&_this->name)); |
816 gotMech = PR_TRUE; | 781 goto loser; |
817 } else if(!PORT_Strcasecmp(subpair->key,CIPHER_FLAGS_STR
ING)) { | 782 } |
818 endptr=NULL; | 783 Pk11Install_ListIter_delete(subiter); |
819 | 784 PR_Free(subiter); |
820 if(gotCipher) { | 785 subiter = NULL; |
821 errStr = PR_smprintf(errString[REPEAT_CI
PHER], | 786 gotMech = PR_TRUE; |
822 Pk11Install_PlatformName_GetString(&_this->n
ame)); | 787 } else if (!PORT_Strcasecmp(subpair->key, CIPHER_FLAGS_STRING)) { |
823 goto loser; | 788 endptr = NULL; |
824 } | 789 |
825 subiter = Pk11Install_ListIter_new(subpair->list
); | 790 if (gotCipher) { |
826 subval = subiter->current; | 791 errStr = |
827 if(!subval || (subval->type != STRING_VALUE)) { | 792 PR_smprintf(errString[REPEAT_CIPHER], |
828 errStr = PR_smprintf(errString[BOGUS_CIP
HER_FLAGS], | 793 Pk11Install_PlatformName_GetString(&_this->name)); |
829 Pk11Install_PlatformName_GetString(&_this->n
ame)); | 794 goto loser; |
830 goto loser; | 795 } |
831 } | 796 subiter = Pk11Install_ListIter_new(subpair->list); |
832 _this->cipherFlags = strtol(subval->string, &end
ptr, 0); | 797 subval = subiter->current; |
833 if(*endptr!='\0' || (endptr==subval->string) ) { | 798 if (!subval || (subval->type != STRING_VALUE)) { |
834 errStr = PR_smprintf(errString[BOGUS_CIP
HER_FLAGS], | 799 errStr = |
835 Pk11Install_PlatformName_GetString(&_this->n
ame)); | 800 PR_smprintf(errString[BOGUS_CIPHER_FLAGS], |
836 goto loser; | 801 Pk11Install_PlatformName_GetString(&_this->name)); |
837 } | 802 goto loser; |
838 Pk11Install_ListIter_delete(subiter); | 803 } |
839 PR_Free(subiter); | 804 _this->cipherFlags = strtol(subval->string, &endptr, 0); |
840 subiter=NULL; | 805 if (*endptr != '\0' || (endptr == subval->string)) { |
841 gotCipher = PR_TRUE; | 806 errStr = |
842 } else if(!PORT_Strcasecmp(subpair->key, FILES_STRING))
{ | 807 PR_smprintf(errString[BOGUS_CIPHER_FLAGS], |
843 if(gotFiles) { | 808 Pk11Install_PlatformName_GetString(&_this->name)); |
844 errStr = PR_smprintf(errString[REPEAT_FI
LES], | 809 goto loser; |
845 Pk11Install_PlatformName_GetString(&_this->n
ame)); | 810 } |
846 goto loser; | 811 Pk11Install_ListIter_delete(subiter); |
847 } | 812 PR_Free(subiter); |
848 subiter = Pk11Install_ListIter_new(subpair->list
); | 813 subiter = NULL; |
849 _this->numFiles = subpair->list->numPairs; | 814 gotCipher = PR_TRUE; |
850 _this->files = (Pk11Install_File*) | 815 } else if (!PORT_Strcasecmp(subpair->key, FILES_STRING)) { |
851 PR_Malloc(sizeof(Pk11Install_File)*_this->numFiles); | 816 if (gotFiles) { |
852 for(i=0; i < _this->numFiles; i++,· | 817 errStr = |
853 Pk11Install_ListIter_nextItem(subiter)) { | 818 PR_smprintf(errString[REPEAT_FILES], |
854 Pk11Install_File_init(&_this->files[i]); | 819 Pk11Install_PlatformName_GetString(&_this->name)); |
855 val = subiter->current; | 820 goto loser; |
856 if(val && (val->type==PAIR_VALUE)) { | 821 } |
857 errStr = Pk11Install_File_Genera
te(&_this->files[i],val->pair); | 822 subiter = Pk11Install_ListIter_new(subpair->list); |
858 if(errStr) { | 823 _this->numFiles = subpair->list->numPairs; |
859 tmp = PR_smprintf("%s: %
s",· | 824 _this->files = (Pk11Install_File *)PR_Malloc(sizeof(Pk11Install_File) * |
860 Pk11Install_PlatformName_GetString(&_this
->name),errStr); | 825 _this->numFiles); |
861 PR_smprintf_free(errStr)
; | 826 for (i = 0; i < _this->numFiles; |
862 errStr = tmp; | 827 i++, Pk11Install_ListIter_nextItem(subiter)) { |
863 goto loser; | 828 Pk11Install_File_init(&_this->files[i]); |
864 } | 829 val = subiter->current; |
865 } | 830 if (val && (val->type == PAIR_VALUE)) { |
866 } | 831 errStr = Pk11Install_File_Generate(&_this->files[i], val->pair); |
867 gotFiles = PR_TRUE; | 832 if (errStr) { |
868 } else if(!PORT_Strcasecmp(subpair->key, | 833 tmp = PR_smprintf( |
869 EQUIVALENT_PLATFORM_STRING)) { | 834 "%s: %s", Pk11Install_PlatformName_GetString(&_this->name), |
870 if(gotEquiv) { | 835 errStr); |
871 errStr = PR_smprintf(errString[REPEAT_EQ
UIV], | 836 PR_smprintf_free(errStr); |
872 Pk11Install_PlatformName_GetString(&_this->n
ame)); | 837 errStr = tmp; |
873 goto loser; | 838 goto loser; |
874 } | 839 } |
875 subiter = Pk11Install_ListIter_new(subpair->list
); | 840 } |
876 subval = subiter->current; | 841 } |
877 if(!subval || (subval->type != STRING_VALUE) ) { | 842 gotFiles = PR_TRUE; |
878 errStr = PR_smprintf(errString[BOGUS_EQU
IV], | 843 } else if (!PORT_Strcasecmp(subpair->key, EQUIVALENT_PLATFORM_STRING)) { |
879 Pk11Install_PlatformName_GetString(&_this->name))
; | 844 if (gotEquiv) { |
880 goto loser; | 845 errStr = |
881 } | 846 PR_smprintf(errString[REPEAT_EQUIV], |
882 errStr = Pk11Install_PlatformName_Generate(&_thi
s->equivName, | 847 Pk11Install_PlatformName_GetString(&_this->name)); |
883 subval->string); | 848 goto loser; |
884 if(errStr) { | 849 } |
885 tmp = PR_smprintf("%s: %s",· | 850 subiter = Pk11Install_ListIter_new(subpair->list); |
886 Pk11Install_PlatformName_GetString(&_this->name), er
rStr); | 851 subval = subiter->current; |
887 tmp = PR_smprintf("%s: %s",· | 852 if (!subval || (subval->type != STRING_VALUE)) { |
888 Pk11Install_PlatformName_GetString(&_this->name), er
rStr); | 853 errStr = |
889 PR_smprintf_free(errStr); | 854 PR_smprintf(errString[BOGUS_EQUIV], |
890 errStr = tmp; | 855 Pk11Install_PlatformName_GetString(&_this->name)); |
891 goto loser; | 856 goto loser; |
892 } | 857 } |
893 _this->usesEquiv = PR_TRUE; | 858 errStr = Pk11Install_PlatformName_Generate(&_this->equivName, |
894 } | 859 subval->string); |
895 } | 860 if (errStr) { |
896 } | 861 tmp = PR_smprintf("%s: %s", |
897 | 862 Pk11Install_PlatformName_GetString(&_this->name), |
898 /* Make sure we either have an EquivalentPlatform or all the other info
*/ | 863 errStr); |
899 if(_this->usesEquiv && | 864 tmp = PR_smprintf("%s: %s", |
900 (gotFiles || gotModuleFile || gotModuleName || gotMech || gotCip
her)) { | 865 Pk11Install_PlatformName_GetString(&_this->name), |
901 errStr = PR_smprintf(errString[EQUIV_TOO_MUCH_INFO],· | 866 errStr); |
| 867 PR_smprintf_free(errStr); |
| 868 errStr = tmp; |
| 869 goto loser; |
| 870 } |
| 871 _this->usesEquiv = PR_TRUE; |
| 872 } |
| 873 } |
| 874 } |
| 875 |
| 876 /* Make sure we either have an EquivalentPlatform or all the other info */ |
| 877 if (_this->usesEquiv && |
| 878 (gotFiles || gotModuleFile || gotModuleName || gotMech || gotCipher)) { |
| 879 errStr = PR_smprintf(errString[EQUIV_TOO_MUCH_INFO], |
| 880 Pk11Install_PlatformName_GetString(&_this->name)); |
| 881 goto loser; |
| 882 } |
| 883 if (!gotFiles && !_this->usesEquiv) { |
| 884 errStr = PR_smprintf(errString[NO_FILES], |
| 885 Pk11Install_PlatformName_GetString(&_this->name)); |
| 886 goto loser; |
| 887 } |
| 888 if (!gotModuleFile && !_this->usesEquiv) { |
| 889 errStr = PR_smprintf(errString[NO_MODULE_FILE], |
| 890 Pk11Install_PlatformName_GetString(&_this->name)); |
| 891 goto loser; |
| 892 } |
| 893 if (!gotModuleName && !_this->usesEquiv) { |
| 894 errStr = PR_smprintf(errString[NO_MODULE_NAME], |
| 895 Pk11Install_PlatformName_GetString(&_this->name)); |
| 896 goto loser; |
| 897 } |
| 898 |
| 899 /* Point the modFile pointer to the correct file */ |
| 900 if (gotModuleFile) { |
| 901 for (i = 0; i < _this->numFiles; i++) { |
| 902 if (!PORT_Strcasecmp(_this->moduleFile, _this->files[i].jarPath)) { |
| 903 _this->modFile = i; |
| 904 break; |
| 905 } |
| 906 } |
| 907 if (_this->modFile == -1) { |
| 908 errStr = PR_smprintf(errString[UNKNOWN_MODULE_FILE], _this->moduleFile, |
902 Pk11Install_PlatformName_GetString(&_this->name)); | 909 Pk11Install_PlatformName_GetString(&_this->name)); |
903 » » goto loser; | 910 goto loser; |
904 » } | 911 } |
905 » if(!gotFiles && !_this->usesEquiv) { | 912 } |
906 » » errStr = PR_smprintf(errString[NO_FILES],· | 913 |
907 Pk11Install_PlatformName_GetString(&_this->name)); | |
908 » » goto loser; | |
909 » } | |
910 » if(!gotModuleFile && !_this->usesEquiv) { | |
911 » » errStr= PR_smprintf(errString[NO_MODULE_FILE],· | |
912 Pk11Install_PlatformName_GetString(&_this->name)); | |
913 » » goto loser; | |
914 » } | |
915 » if(!gotModuleName && !_this->usesEquiv) { | |
916 » » errStr = PR_smprintf(errString[NO_MODULE_NAME],· | |
917 Pk11Install_PlatformName_GetString(&_this->name)); | |
918 » » goto loser; | |
919 » } | |
920 | |
921 » /* Point the modFile pointer to the correct file */ | |
922 » if(gotModuleFile) { | |
923 » » for(i=0; i < _this->numFiles; i++) { | |
924 » » » if(!PORT_Strcasecmp(_this->moduleFile, _this->files[i].j
arPath) ) { | |
925 » » » » _this->modFile = i; | |
926 » » » » break; | |
927 » » » } | |
928 » » } | |
929 » » if(_this->modFile==-1) { | |
930 » » » errStr = PR_smprintf(errString[UNKNOWN_MODULE_FILE],· | |
931 _this->moduleFile, | |
932 Pk11Install_PlatformName_GetString(&_this->name)); | |
933 » » » goto loser; | |
934 » » } | |
935 » } | |
936 »······· | |
937 loser: | 914 loser: |
938 » if(iter) { | 915 if (iter) { |
939 » » PR_Free(iter); | 916 PR_Free(iter); |
940 » } | 917 } |
941 » if(subiter) { | 918 if (subiter) { |
942 » » PR_Free(subiter); | 919 PR_Free(subiter); |
943 » } | 920 } |
944 » return errStr; | 921 return errStr; |
945 } | 922 } |
946 | 923 |
947 /* | 924 /* |
948 ////////////////////////////////////////////////////////////////////////// | 925 ////////////////////////////////////////////////////////////////////////// |
949 // Method: Print | 926 // Method: Print |
950 // Class: Pk11Install_Platform | 927 // Class: Pk11Install_Platform |
951 */ | 928 */ |
952 void | 929 void Pk11Install_Platform_Print(Pk11Install_Platform *_this, int pad) { |
953 Pk11Install_Platform_Print(Pk11Install_Platform* _this, int pad) | 930 int i; |
954 { | 931 |
955 » int i; | 932 PAD(pad); |
956 | 933 printf("Name:\n"); |
957 » PAD(pad); printf("Name:\n");· | 934 Pk11Install_PlatformName_Print(&_this->name, pad + PADINC); |
958 » Pk11Install_PlatformName_Print(&_this->name,pad+PADINC); | 935 PAD(pad); |
959 » PAD(pad); printf("equivName:\n");· | 936 printf("equivName:\n"); |
960 » Pk11Install_PlatformName_Print(&_this->equivName,pad+PADINC); | 937 Pk11Install_PlatformName_Print(&_this->equivName, pad + PADINC); |
961 » PAD(pad); | 938 PAD(pad); |
962 » if(_this->usesEquiv) { | 939 if (_this->usesEquiv) { |
963 » » printf("Uses equiv, which points to:\n"); | 940 printf("Uses equiv, which points to:\n"); |
964 » » Pk11Install_Platform_Print(_this->equiv,pad+PADINC); | 941 Pk11Install_Platform_Print(_this->equiv, pad + PADINC); |
965 » } else { | 942 } else { |
966 » » printf("Doesn't use equiv\n"); | 943 printf("Doesn't use equiv\n"); |
967 » } | 944 } |
968 » PAD(pad);· | 945 PAD(pad); |
969 » printf("Module File: %s\n", _this->moduleFile ? _this->moduleFile | 946 printf("Module File: %s\n", _this->moduleFile ? _this->moduleFile : "<NULL>"); |
970 : "<NULL>"); | 947 PAD(pad); |
971 » PAD(pad); printf("mechFlags: %lx\n", _this->mechFlags); | 948 printf("mechFlags: %lx\n", _this->mechFlags); |
972 » PAD(pad); printf("cipherFlags: %lx\n", _this->cipherFlags); | 949 PAD(pad); |
973 » PAD(pad); printf("Files:\n"); | 950 printf("cipherFlags: %lx\n", _this->cipherFlags); |
974 » for(i=0; i < _this->numFiles; i++) { | 951 PAD(pad); |
975 » » Pk11Install_File_Print(&_this->files[i],pad+PADINC); | 952 printf("Files:\n"); |
976 » » PAD(pad); printf("--------------------\n"); | 953 for (i = 0; i < _this->numFiles; i++) { |
977 » } | 954 Pk11Install_File_Print(&_this->files[i], pad + PADINC); |
| 955 PAD(pad); |
| 956 printf("--------------------\n"); |
| 957 } |
978 } | 958 } |
979 | 959 |
980 /* | 960 /* |
981 ////////////////////////////////////////////////////////////////////////// | 961 ////////////////////////////////////////////////////////////////////////// |
982 // Method: Pk11Install_Info | 962 // Method: Pk11Install_Info |
983 // Class: Pk11Install_Info | 963 // Class: Pk11Install_Info |
984 */ | 964 */ |
985 Pk11Install_Info* | 965 Pk11Install_Info *Pk11Install_Info_new() { |
986 Pk11Install_Info_new() | 966 Pk11Install_Info *new_this; |
987 { | 967 new_this = (Pk11Install_Info *)PR_Malloc(sizeof(Pk11Install_Info)); |
988 » Pk11Install_Info* new_this; | 968 Pk11Install_Info_init(new_this); |
989 » new_this = (Pk11Install_Info*)PR_Malloc(sizeof(Pk11Install_Info)); | 969 return new_this; |
990 » Pk11Install_Info_init(new_this); | 970 } |
991 » return new_this; | 971 |
992 } | 972 void Pk11Install_Info_init(Pk11Install_Info *_this) { |
993 | 973 _this->platforms = NULL; |
994 void | 974 _this->numPlatforms = 0; |
995 Pk11Install_Info_init(Pk11Install_Info* _this) | 975 _this->forwardCompatible = NULL; |
996 { | 976 _this->numForwardCompatible = 0; |
997 » _this->platforms = NULL; | |
998 » _this->numPlatforms = 0; | |
999 » _this->forwardCompatible = NULL; | |
1000 » _this->numForwardCompatible = 0; | |
1001 } | 977 } |
1002 | 978 |
1003 /* | 979 /* |
1004 ////////////////////////////////////////////////////////////////////////// | 980 ////////////////////////////////////////////////////////////////////////// |
1005 // Method: ~Pk11Install_Info | 981 // Method: ~Pk11Install_Info |
1006 // Class: Pk11Install_Info | 982 // Class: Pk11Install_Info |
1007 */ | 983 */ |
1008 void | 984 void Pk11Install_Info_delete(Pk11Install_Info *_this) { |
1009 Pk11Install_Info_delete(Pk11Install_Info* _this) | 985 Pk11Install_Info_Cleanup(_this); |
1010 { | |
1011 » Pk11Install_Info_Cleanup(_this); | |
1012 } | 986 } |
1013 | 987 |
1014 /* | 988 /* |
1015 ////////////////////////////////////////////////////////////////////////// | 989 ////////////////////////////////////////////////////////////////////////// |
1016 // Method: Cleanup | 990 // Method: Cleanup |
1017 // Class: Pk11Install_Info | 991 // Class: Pk11Install_Info |
1018 */ | 992 */ |
1019 void | 993 void Pk11Install_Info_Cleanup(Pk11Install_Info *_this) { |
1020 Pk11Install_Info_Cleanup(Pk11Install_Info* _this) | 994 int i; |
1021 { | 995 if (_this->platforms) { |
1022 » int i; | 996 for (i = 0; i < _this->numPlatforms; i++) { |
1023 » if(_this->platforms) { | 997 Pk11Install_Platform_delete(&_this->platforms[i]); |
1024 » » for (i=0;i<_this->numPlatforms;i++) { | 998 } |
1025 » » » Pk11Install_Platform_delete(&_this->platforms[i]); | 999 PR_Free(&_this->platforms); |
1026 » » } | 1000 _this->platforms = NULL; |
1027 » » PR_Free(&_this->platforms); | 1001 _this->numPlatforms = 0; |
1028 » » _this->platforms = NULL; | 1002 } |
1029 » » _this->numPlatforms = 0; | 1003 |
1030 » } | 1004 if (_this->forwardCompatible) { |
1031 | 1005 for (i = 0; i < _this->numForwardCompatible; i++) { |
1032 » if(_this->forwardCompatible) { | 1006 Pk11Install_PlatformName_delete(&_this->forwardCompatible[i]); |
1033 » » for (i=0;i<_this->numForwardCompatible;i++) { | 1007 } |
1034 » » » Pk11Install_PlatformName_delete(&_this->forwardCompatibl
e[i]); | 1008 PR_Free(&_this->forwardCompatible); |
1035 » » } | 1009 _this->numForwardCompatible = 0; |
1036 » » PR_Free(&_this->forwardCompatible); | 1010 } |
1037 » » _this->numForwardCompatible = 0; | |
1038 » } | |
1039 } | 1011 } |
1040 | 1012 |
1041 /* | 1013 /* |
1042 ////////////////////////////////////////////////////////////////////////// | 1014 ////////////////////////////////////////////////////////////////////////// |
1043 // Method: Generate | 1015 // Method: Generate |
1044 // Class: Pk11Install_Info | 1016 // Class: Pk11Install_Info |
1045 // Takes: Pk11Install_ValueList *list, the top-level list | 1017 // Takes: Pk11Install_ValueList *list, the top-level list |
1046 // resulting from parsing an installer file. | 1018 // resulting from parsing an installer file. |
1047 // Returns: char*, NULL if successful, otherwise an error string. | 1019 // Returns: char*, NULL if successful, otherwise an error string. |
1048 // Caller is responsible for freeing memory. | 1020 // Caller is responsible for freeing memory. |
1049 */ | 1021 */ |
1050 char* | 1022 char *Pk11Install_Info_Generate(Pk11Install_Info *_this, |
1051 Pk11Install_Info_Generate(Pk11Install_Info* _this, | 1023 const Pk11Install_ValueList *list) { |
1052 const Pk11Install_ValueList *list) | 1024 char *errStr; |
1053 { | 1025 Pk11Install_ListIter *iter; |
1054 » char *errStr; | 1026 Pk11Install_Value *val; |
1055 » Pk11Install_ListIter *iter; | 1027 Pk11Install_Pair *pair; |
1056 » Pk11Install_Value *val; | 1028 Pk11Install_ListIter *subiter; |
1057 » Pk11Install_Pair *pair; | 1029 Pk11Install_Value *subval; |
1058 » Pk11Install_ListIter *subiter; | 1030 Pk11Install_Platform *first, *second; |
1059 » Pk11Install_Value *subval; | 1031 int i, j; |
1060 » Pk11Install_Platform *first, *second; | 1032 |
1061 » int i, j; | 1033 errStr = NULL; |
1062 | 1034 iter = subiter = NULL; |
1063 » errStr=NULL; | 1035 Pk11Install_Info_Cleanup(_this); |
1064 » iter=subiter=NULL; | 1036 |
1065 » Pk11Install_Info_Cleanup(_this); | 1037 iter = Pk11Install_ListIter_new(list); |
1066 | 1038 for (; (val = iter->current); Pk11Install_ListIter_nextItem(iter)) { |
1067 » iter = Pk11Install_ListIter_new(list); | 1039 if (val->type == PAIR_VALUE) { |
1068 » for( ; (val=iter->current); Pk11Install_ListIter_nextItem(iter)) { | 1040 pair = val->pair; |
1069 » » if(val->type == PAIR_VALUE) { | 1041 |
1070 » » » pair = val->pair; | 1042 if (!PORT_Strcasecmp(pair->key, FORWARD_COMPATIBLE_STRING)) { |
1071 | 1043 subiter = Pk11Install_ListIter_new(pair->list); |
1072 » » » if(!PORT_Strcasecmp(pair->key, FORWARD_COMPATIBLE_STRING
)) { | 1044 _this->numForwardCompatible = pair->list->numStrings; |
1073 » » » » subiter = Pk11Install_ListIter_new(pair->list); | 1045 _this->forwardCompatible = (Pk11Install_PlatformName *)PR_Malloc( |
1074 » » » » _this->numForwardCompatible = pair->list->numStr
ings; | 1046 sizeof(Pk11Install_PlatformName) * _this->numForwardCompatible); |
1075 » » » » _this->forwardCompatible = (Pk11Install_Platform
Name*) | 1047 for (i = 0; i < _this->numForwardCompatible; |
1076 PR_Malloc(sizeof(Pk11Install_PlatformNam
e)* | 1048 i++, Pk11Install_ListIter_nextItem(subiter)) { |
1077 _this->numForwardCompatible); | 1049 subval = subiter->current; |
1078 » » » » for(i=0; i < _this->numForwardCompatible; i++, | 1050 if (subval->type == STRING_VALUE) { |
1079 Pk11Install_ListIter_nextItem(subiter)) { | 1051 errStr = Pk11Install_PlatformName_Generate( |
1080 » » » » » subval = subiter->current; | 1052 &_this->forwardCompatible[i], subval->string); |
1081 » » » » » if(subval->type == STRING_VALUE) { | 1053 if (errStr) { |
1082 » » » » » » errStr = Pk11Install_PlatformNam
e_Generate( | 1054 goto loser; |
1083 &_this->forwardCompatible[i], subval->string); | 1055 } |
1084 » » » » » » if(errStr) { | 1056 } |
1085 » » » » » » » goto loser; | 1057 } |
1086 » » » » » » } | 1058 Pk11Install_ListIter_delete(subiter); |
1087 » » » » » } | 1059 PR_Free(subiter); |
1088 » » » » } | 1060 subiter = NULL; |
1089 » » » » Pk11Install_ListIter_delete(subiter); | 1061 } else if (!PORT_Strcasecmp(pair->key, PLATFORMS_STRING)) { |
1090 » » » » PR_Free(subiter); | 1062 subiter = Pk11Install_ListIter_new(pair->list); |
1091 » » » » subiter = NULL; | 1063 _this->numPlatforms = pair->list->numPairs; |
1092 » » » } else if(!PORT_Strcasecmp(pair->key, PLATFORMS_STRING))
{ | 1064 _this->platforms = (Pk11Install_Platform *)PR_Malloc( |
1093 » » » » subiter = Pk11Install_ListIter_new(pair->list); | 1065 sizeof(Pk11Install_Platform) * _this->numPlatforms); |
1094 » » » » _this->numPlatforms = pair->list->numPairs; | 1066 for (i = 0; i < _this->numPlatforms; |
1095 » » » » _this->platforms = (Pk11Install_Platform*) | 1067 i++, Pk11Install_ListIter_nextItem(subiter)) { |
1096 PR_Malloc(sizeof(Pk11Install_Platform)* | 1068 Pk11Install_Platform_init(&_this->platforms[i]); |
1097 _this->numPlatforms); | 1069 subval = subiter->current; |
1098 » » » » for(i=0; i < _this->numPlatforms; i++, | 1070 if (subval->type == PAIR_VALUE) { |
1099 Pk11Install_ListIter_nextItem(subiter)) { | 1071 errStr = Pk11Install_Platform_Generate(&_this->platforms[i], |
1100 » » » » » Pk11Install_Platform_init(&_this->platf
orms[i]); | 1072 subval->pair); |
1101 » » » » » subval = subiter->current; | 1073 if (errStr) { |
1102 » » » » » if(subval->type == PAIR_VALUE) { | 1074 goto loser; |
1103 » » » » » » errStr = Pk11Install_Platform_Ge
nerate(&_this->platforms[i],subval->pair); | 1075 } |
1104 » » » » » » if(errStr) { | 1076 } |
1105 » » » » » » » goto loser; | 1077 } |
1106 » » » » » » } | 1078 Pk11Install_ListIter_delete(subiter); |
1107 » » » » » } | 1079 PR_Free(subiter); |
1108 » » » » } | 1080 subiter = NULL; |
1109 » » » » Pk11Install_ListIter_delete(subiter); | 1081 } |
1110 » » » » PR_Free(subiter); | 1082 } |
1111 » » » » subiter = NULL; | 1083 } |
1112 » » » } | 1084 |
1113 » » } | 1085 if (_this->numPlatforms == 0) { |
1114 » } | 1086 errStr = PR_smprintf(errString[NO_PLATFORMS]); |
1115 | 1087 goto loser; |
1116 » if(_this->numPlatforms == 0) { | 1088 } |
1117 » » errStr = PR_smprintf(errString[NO_PLATFORMS]); | 1089 |
1118 » » goto loser; | 1090 /* |
1119 » } | 1091 // |
1120 | 1092 // Now process equivalent platforms |
1121 /* | 1093 // |
1122 » // | 1094 |
1123 » // Now process equivalent platforms | 1095 // First the naive pass |
1124 » // | 1096 */ |
1125 | 1097 for (i = 0; i < _this->numPlatforms; i++) { |
1126 » // First the naive pass | 1098 if (_this->platforms[i].usesEquiv) { |
1127 */ | 1099 _this->platforms[i].equiv = NULL; |
1128 » for(i=0; i < _this->numPlatforms; i++) { | 1100 for (j = 0; j < _this->numPlatforms; j++) { |
1129 » » if(_this->platforms[i].usesEquiv) { | 1101 if (Pk11Install_PlatformName_equal(&_this->platforms[i].equivName, |
1130 » » » _this->platforms[i].equiv = NULL; | |
1131 » » » for(j=0; j < _this->numPlatforms; j++) { | |
1132 » » » » if (Pk11Install_PlatformName_equal(&_this->platf
orms[i].equivName, | |
1133 &_this->platforms[j].name)) { | 1102 &_this->platforms[j].name)) { |
1134 » » » » » if(i==j) { | 1103 if (i == j) { |
1135 » » » » » » errStr = PR_smprintf(errString[E
QUIV_LOOP], | 1104 errStr = PR_smprintf( |
1136 Pk11Install_PlatformName_GetString(&_this->platfor
ms[i].name)); | 1105 errString[EQUIV_LOOP], |
1137 » » » » » » goto loser; | 1106 Pk11Install_PlatformName_GetString(&_this->platforms[i].name)); |
1138 » » » » » } | 1107 goto loser; |
1139 » » » » » _this->platforms[i].equiv = &_this->plat
forms[j]; | 1108 } |
1140 » » » » » break; | 1109 _this->platforms[i].equiv = &_this->platforms[j]; |
1141 » » » » } | 1110 break; |
1142 » » » } | 1111 } |
1143 » » » if(_this->platforms[i].equiv == NULL) { | 1112 } |
1144 » » » » errStr = PR_smprintf(errString[BOGUS_EQUIV], | 1113 if (_this->platforms[i].equiv == NULL) { |
1145 Pk11Install_PlatformName_GetString(&_this->platforms[i].n
ame)); | 1114 errStr = PR_smprintf( |
1146 » » » » goto loser; | 1115 errString[BOGUS_EQUIV], |
1147 » » » } | 1116 Pk11Install_PlatformName_GetString(&_this->platforms[i].name)); |
1148 » » } | 1117 goto loser; |
1149 » } | 1118 } |
1150 | 1119 } |
1151 /* | 1120 } |
1152 » // Now the intelligent pass, which will also detect loops. | 1121 |
1153 » // We will send two pointers through the linked list of equivalent | 1122 /* |
1154 » // platforms. Both start with the current node. "first" traverses | 1123 // Now the intelligent pass, which will also detect loops. |
1155 » // two nodes for each iteration. "second" lags behind, only traversing | 1124 // We will send two pointers through the linked list of equivalent |
1156 » // one node per iteration. Eventually one of two things will happen: | 1125 // platforms. Both start with the current node. "first" traverses |
1157 » // first will hit the end of the list (a platform that doesn't use | 1126 // two nodes for each iteration. "second" lags behind, only |
1158 » // an equivalency), or first will equal second if there is a loop. | 1127 traversing |
1159 */ | 1128 // one node per iteration. Eventually one of two things will happen: |
1160 » for(i=0; i < _this->numPlatforms; i++) { | 1129 // first will hit the end of the list (a platform that doesn't use |
1161 » » if(_this->platforms[i].usesEquiv) { | 1130 // an equivalency), or first will equal second if there is a loop. |
1162 » » » second = _this->platforms[i].equiv; | 1131 */ |
1163 » » » if(!second->usesEquiv) { | 1132 for (i = 0; i < _this->numPlatforms; i++) { |
1164 » » » » /* The first link is the terminal node */ | 1133 if (_this->platforms[i].usesEquiv) { |
1165 » » » » continue; | 1134 second = _this->platforms[i].equiv; |
1166 » » » } | 1135 if (!second->usesEquiv) { |
1167 » » » first = second->equiv; | 1136 /* The first link is the terminal node */ |
1168 » » » while(first->usesEquiv) { | 1137 continue; |
1169 » » » » if(first == second) { | 1138 } |
1170 » » » » » errStr = PR_smprintf(errString[EQUIV_LOO
P], | 1139 first = second->equiv; |
1171 Pk11Install_PlatformName_GetString(&_this->platforms[i]
.name)); | 1140 while (first->usesEquiv) { |
1172 » » » » » goto loser; | 1141 if (first == second) { |
1173 » » » » } | 1142 errStr = PR_smprintf( |
1174 » » » » first = first->equiv; | 1143 errString[EQUIV_LOOP], |
1175 » » » » if(!first->usesEquiv) { | 1144 Pk11Install_PlatformName_GetString(&_this->platforms[i].name)); |
1176 » » » » » break; | 1145 goto loser; |
1177 » » » » } | 1146 } |
1178 » » » » if(first == second) { | 1147 first = first->equiv; |
1179 » » » » » errStr = PR_smprintf(errString[EQUIV_LOO
P], | 1148 if (!first->usesEquiv) { |
1180 Pk11Install_PlatformName_GetString(&_this->platforms[i].n
ame)); | 1149 break; |
1181 » » » » » goto loser; | 1150 } |
1182 » » » » } | 1151 if (first == second) { |
1183 » » » » second = second->equiv; | 1152 errStr = PR_smprintf( |
1184 » » » » first = first->equiv; | 1153 errString[EQUIV_LOOP], |
1185 » » » } | 1154 Pk11Install_PlatformName_GetString(&_this->platforms[i].name)); |
1186 » » » _this->platforms[i].equiv = first; | 1155 goto loser; |
1187 » » } | 1156 } |
1188 » } | 1157 second = second->equiv; |
| 1158 first = first->equiv; |
| 1159 } |
| 1160 _this->platforms[i].equiv = first; |
| 1161 } |
| 1162 } |
1189 | 1163 |
1190 loser: | 1164 loser: |
1191 » if(iter) { | 1165 if (iter) { |
1192 » » Pk11Install_ListIter_delete(iter); | 1166 Pk11Install_ListIter_delete(iter); |
1193 » » PR_Free(iter); | 1167 PR_Free(iter); |
1194 » » iter = NULL; | 1168 iter = NULL; |
1195 » } | 1169 } |
1196 » if(subiter) { | 1170 if (subiter) { |
1197 » » Pk11Install_ListIter_delete(subiter); | 1171 Pk11Install_ListIter_delete(subiter); |
1198 » » PR_Free(subiter); | 1172 PR_Free(subiter); |
1199 » » subiter = NULL; | 1173 subiter = NULL; |
1200 » } | 1174 } |
1201 » return errStr; | 1175 return errStr; |
1202 } | 1176 } |
1203 | 1177 |
1204 /* | 1178 /* |
1205 ////////////////////////////////////////////////////////////////////////// | 1179 ////////////////////////////////////////////////////////////////////////// |
1206 // Method: GetBestPlatform | 1180 // Method: GetBestPlatform |
1207 // Class: Pk11Install_Info | 1181 // Class: Pk11Install_Info |
1208 // Takes: char *myPlatform, the platform we are currently running | 1182 // Takes: char *myPlatform, the platform we are currently running |
1209 // on. | 1183 // on. |
1210 */ | 1184 */ |
1211 Pk11Install_Platform* | 1185 Pk11Install_Platform *Pk11Install_Info_GetBestPlatform(Pk11Install_Info *_this, |
1212 Pk11Install_Info_GetBestPlatform(Pk11Install_Info* _this, char *myPlatform) | 1186 char *myPlatform) { |
1213 { | 1187 Pk11Install_PlatformName plat; |
1214 » Pk11Install_PlatformName plat; | 1188 char *errStr; |
1215 » char *errStr; | 1189 int i, j; |
1216 » int i, j; | 1190 |
1217 | 1191 errStr = NULL; |
1218 » errStr=NULL; | 1192 |
1219 | 1193 Pk11Install_PlatformName_init(&plat); |
1220 » Pk11Install_PlatformName_init(&plat); | 1194 if ((errStr = Pk11Install_PlatformName_Generate(&plat, myPlatform))) { |
1221 » if( (errStr=Pk11Install_PlatformName_Generate(&plat, myPlatform)) ) { | 1195 PR_smprintf_free(errStr); |
1222 » » PR_smprintf_free(errStr); | 1196 return NULL; |
1223 » » return NULL; | 1197 } |
1224 » } | 1198 |
1225 | 1199 /* First try real platforms */ |
1226 » /* First try real platforms */ | 1200 for (i = 0; i < _this->numPlatforms; i++) { |
1227 » for(i=0; i < _this->numPlatforms; i++) { | 1201 if (Pk11Install_PlatformName_equal(&_this->platforms[i].name, &plat)) { |
1228 » » if(Pk11Install_PlatformName_equal(&_this->platforms[i].name,&pla
t)) { | 1202 if (_this->platforms[i].equiv) { |
1229 » » » if(_this->platforms[i].equiv) { | 1203 return _this->platforms[i].equiv; |
1230 » » » » return _this->platforms[i].equiv; | 1204 } else { |
1231 » » » } | 1205 return &_this->platforms[i]; |
1232 » » » else { | 1206 } |
1233 » » » » return &_this->platforms[i]; | 1207 } |
1234 » » » } | 1208 } |
1235 » » } | 1209 |
1236 » } | 1210 /* Now try forward compatible platforms */ |
1237 | 1211 for (i = 0; i < _this->numForwardCompatible; i++) { |
1238 » /* Now try forward compatible platforms */ | 1212 if (Pk11Install_PlatformName_lteq(&_this->forwardCompatible[i], &plat)) { |
1239 » for(i=0; i < _this->numForwardCompatible; i++) { | 1213 break; |
1240 » » if(Pk11Install_PlatformName_lteq(&_this->forwardCompatible[i],&p
lat)) { | 1214 } |
1241 » » » break; | 1215 } |
1242 » » } | 1216 if (i == _this->numForwardCompatible) { |
1243 » } | 1217 return NULL; |
1244 » if(i == _this->numForwardCompatible) { | 1218 } |
1245 » » return NULL; | 1219 |
1246 » } | 1220 /* Got a forward compatible name, find the actual platform. */ |
1247 | 1221 for (j = 0; j < _this->numPlatforms; j++) { |
1248 » /* Got a forward compatible name, find the actual platform. */ | 1222 if (Pk11Install_PlatformName_equal(&_this->platforms[j].name, |
1249 » for(j=0; j < _this->numPlatforms; j++) { | 1223 &_this->forwardCompatible[i])) { |
1250 » » if(Pk11Install_PlatformName_equal(&_this->platforms[j].name, | 1224 if (_this->platforms[j].equiv) { |
1251 &_this->forwardCompatible[i])) { | 1225 return _this->platforms[j].equiv; |
1252 » » » if(_this->platforms[j].equiv) { | 1226 } else { |
1253 » » » » return _this->platforms[j].equiv; | 1227 return &_this->platforms[j]; |
1254 » » » } else { | 1228 } |
1255 » » » » return &_this->platforms[j]; | 1229 } |
1256 » » » } | 1230 } |
1257 » » } | 1231 |
1258 » } | 1232 return NULL; |
1259 | |
1260 » return NULL; | |
1261 } | 1233 } |
1262 | 1234 |
1263 /* | 1235 /* |
1264 ////////////////////////////////////////////////////////////////////////// | 1236 ////////////////////////////////////////////////////////////////////////// |
1265 // Method: Print | 1237 // Method: Print |
1266 // Class: Pk11Install_Info | 1238 // Class: Pk11Install_Info |
1267 */ | 1239 */ |
1268 void | 1240 void Pk11Install_Info_Print(Pk11Install_Info *_this, int pad) { |
1269 Pk11Install_Info_Print(Pk11Install_Info* _this, int pad) | 1241 int i; |
1270 { | 1242 |
1271 » int i; | 1243 PAD(pad); |
1272 | 1244 printf("Forward Compatible:\n"); |
1273 » PAD(pad); printf("Forward Compatible:\n"); | 1245 for (i = 0; i < _this->numForwardCompatible; i++) { |
1274 » for(i = 0; i < _this->numForwardCompatible; i++) { | 1246 Pk11Install_PlatformName_Print(&_this->forwardCompatible[i], pad + PADINC); |
1275 » » Pk11Install_PlatformName_Print(&_this->forwardCompatible[i],pad+
PADINC); | 1247 PAD(pad); |
1276 » » PAD(pad); printf("-------------------\n"); | 1248 printf("-------------------\n"); |
1277 » } | 1249 } |
1278 » PAD(pad); printf("Platforms:\n"); | 1250 PAD(pad); |
1279 » for( i = 0; i < _this->numPlatforms; i++) { | 1251 printf("Platforms:\n"); |
1280 » » Pk11Install_Platform_Print(&_this->platforms[i],pad+PADINC); | 1252 for (i = 0; i < _this->numPlatforms; i++) { |
1281 » » PAD(pad); printf("-------------------\n"); | 1253 Pk11Install_Platform_Print(&_this->platforms[i], pad + PADINC); |
1282 » } | 1254 PAD(pad); |
1283 } | 1255 printf("-------------------\n"); |
1284 | 1256 } |
1285 /* | 1257 } |
1286 ////////////////////////////////////////////////////////////////////////// | 1258 |
1287 */ | 1259 /* |
1288 static char* | 1260 ////////////////////////////////////////////////////////////////////////// |
1289 PR_Strdup(const char* str) | 1261 */ |
1290 { | 1262 static char *PR_Strdup(const char *str) { |
1291 » char *tmp; | 1263 char *tmp; |
1292 » tmp = (char*) PR_Malloc((unsigned int)(strlen(str)+1)); | 1264 tmp = (char *)PR_Malloc((unsigned int)(strlen(str) + 1)); |
1293 » strcpy(tmp, str); | 1265 strcpy(tmp, str); |
1294 » return tmp; | 1266 return tmp; |
1295 } | 1267 } |
1296 | 1268 |
1297 /* The global value list, the top of the tree */ | 1269 /* The global value list, the top of the tree */ |
1298 Pk11Install_ValueList* Pk11Install_valueList=NULL; | 1270 Pk11Install_ValueList *Pk11Install_valueList = NULL; |
1299 | 1271 |
1300 /****************************************************************************/ | 1272 /****************************************************************************/ |
1301 void | 1273 void Pk11Install_ValueList_AddItem(Pk11Install_ValueList *_this, |
1302 Pk11Install_ValueList_AddItem(Pk11Install_ValueList* _this, | 1274 Pk11Install_Value *item) { |
1303 Pk11Install_Value *item) | 1275 _this->numItems++; |
1304 { | 1276 if (item->type == STRING_VALUE) { |
1305 » _this->numItems++; | 1277 _this->numStrings++; |
1306 » if (item->type == STRING_VALUE) { | 1278 } else { |
1307 » » _this->numStrings++; | 1279 _this->numPairs++; |
1308 » } else { | 1280 } |
1309 » » _this->numPairs++; | 1281 item->next = _this->head; |
1310 » } | 1282 _this->head = item; |
1311 » item->next = _this->head; | |
1312 » _this->head = item; | |
1313 } | 1283 } |
1314 | 1284 |
1315 /****************************************************************************/ | 1285 /****************************************************************************/ |
1316 Pk11Install_ListIter* | 1286 Pk11Install_ListIter *Pk11Install_ListIter_new_default() { |
1317 Pk11Install_ListIter_new_default() | 1287 Pk11Install_ListIter *new_this; |
1318 { | 1288 new_this = (Pk11Install_ListIter *)PR_Malloc(sizeof(Pk11Install_ListIter)); |
1319 » Pk11Install_ListIter* new_this; | 1289 Pk11Install_ListIter_init(new_this); |
1320 » new_this = (Pk11Install_ListIter*) | 1290 return new_this; |
1321 PR_Malloc(sizeof(Pk11Install_ListIter)); | |
1322 » Pk11Install_ListIter_init(new_this); | |
1323 » return new_this; | |
1324 } | 1291 } |
1325 | 1292 |
1326 /****************************************************************************/ | 1293 /****************************************************************************/ |
1327 void | 1294 void Pk11Install_ListIter_init(Pk11Install_ListIter *_this) { |
1328 Pk11Install_ListIter_init(Pk11Install_ListIter* _this) | 1295 _this->list = NULL; |
1329 { | 1296 _this->current = NULL; |
1330 » _this->list = NULL; | |
1331 » _this->current = NULL; | |
1332 } | 1297 } |
1333 | 1298 |
1334 /****************************************************************************/ | 1299 /****************************************************************************/ |
1335 Pk11Install_ListIter* | 1300 Pk11Install_ListIter *Pk11Install_ListIter_new( |
1336 Pk11Install_ListIter_new(const Pk11Install_ValueList *_list) | 1301 const Pk11Install_ValueList *_list) { |
1337 { | 1302 Pk11Install_ListIter *new_this; |
1338 » Pk11Install_ListIter* new_this; | 1303 new_this = (Pk11Install_ListIter *)PR_Malloc(sizeof(Pk11Install_ListIter)); |
1339 » new_this = (Pk11Install_ListIter*) | 1304 new_this->list = _list; |
1340 PR_Malloc(sizeof(Pk11Install_ListIter)); | 1305 new_this->current = _list->head; |
1341 » new_this->list = _list; | 1306 return new_this; |
1342 » new_this->current = _list->head; | |
1343 » return new_this; | |
1344 } | 1307 } |
1345 | 1308 |
1346 /****************************************************************************/ | 1309 /****************************************************************************/ |
1347 void | 1310 void Pk11Install_ListIter_delete(Pk11Install_ListIter *_this) { |
1348 Pk11Install_ListIter_delete(Pk11Install_ListIter* _this) | 1311 _this->list = NULL; |
1349 { | 1312 _this->current = NULL; |
1350 » _this->list=NULL; | |
1351 » _this->current=NULL; | |
1352 } | 1313 } |
1353 | 1314 |
1354 /****************************************************************************/ | 1315 /****************************************************************************/ |
1355 void | 1316 void Pk11Install_ListIter_reset(Pk11Install_ListIter *_this) { |
1356 Pk11Install_ListIter_reset(Pk11Install_ListIter* _this) | 1317 if (_this->list) { |
1357 { | 1318 _this->current = _this->list->head; |
1358 » if(_this->list) { | 1319 } |
1359 » » _this->current = _this->list->head; | |
1360 » } | |
1361 } | 1320 } |
1362 | 1321 |
1363 /*************************************************************************/ | 1322 /*************************************************************************/ |
1364 Pk11Install_Value* | 1323 Pk11Install_Value *Pk11Install_ListIter_nextItem(Pk11Install_ListIter *_this) { |
1365 Pk11Install_ListIter_nextItem(Pk11Install_ListIter* _this) | 1324 if (_this->current) { |
1366 { | 1325 _this->current = _this->current->next; |
1367 » if(_this->current) { | 1326 } |
1368 » » _this->current = _this->current->next; | 1327 |
1369 » } | 1328 return _this->current; |
1370 | |
1371 » return _this->current; | |
1372 } | 1329 } |
1373 | 1330 |
1374 /****************************************************************************/ | 1331 /****************************************************************************/ |
1375 Pk11Install_ValueList* | 1332 Pk11Install_ValueList *Pk11Install_ValueList_new() { |
1376 Pk11Install_ValueList_new() | 1333 Pk11Install_ValueList *new_this; |
1377 { | 1334 new_this = (Pk11Install_ValueList *)PR_Malloc(sizeof(Pk11Install_ValueList)); |
1378 » Pk11Install_ValueList* new_this; | 1335 new_this->numItems = 0; |
1379 » new_this = (Pk11Install_ValueList*) | 1336 new_this->numPairs = 0; |
1380 PR_Malloc(sizeof(Pk11Install_ValueList)); | 1337 new_this->numStrings = 0; |
1381 » new_this->numItems = 0; | 1338 new_this->head = NULL; |
1382 » new_this->numPairs = 0; | 1339 return new_this; |
1383 » new_this->numStrings = 0; | |
1384 » new_this->head = NULL; | |
1385 » return new_this; | |
1386 } | 1340 } |
1387 | 1341 |
1388 /****************************************************************************/ | 1342 /****************************************************************************/ |
1389 void | 1343 void Pk11Install_ValueList_delete(Pk11Install_ValueList *_this) { |
1390 Pk11Install_ValueList_delete(Pk11Install_ValueList* _this) | 1344 |
1391 { | 1345 Pk11Install_Value *tmp; |
1392 | 1346 Pk11Install_Value *list; |
1393 » Pk11Install_Value *tmp; | 1347 list = _this->head; |
1394 » Pk11Install_Value *list; | 1348 |
1395 » list = _this->head; | 1349 while (list != NULL) { |
1396 » | 1350 tmp = list; |
1397 » while(list != NULL) { | 1351 list = list->next; |
1398 » » tmp = list; | 1352 PR_Free(tmp); |
1399 » » list = list->next; | 1353 } |
1400 » » PR_Free(tmp); | 1354 PR_Free(_this); |
1401 » } | |
1402 » PR_Free(_this); | |
1403 } | 1355 } |
1404 | 1356 |
1405 /****************************************************************************/ | 1357 /****************************************************************************/ |
1406 Pk11Install_Value* | 1358 Pk11Install_Value *Pk11Install_Value_new_default() { |
1407 Pk11Install_Value_new_default() | 1359 Pk11Install_Value *new_this; |
1408 { | 1360 new_this = (Pk11Install_Value *)PR_Malloc(sizeof(Pk11Install_Value)); |
1409 » Pk11Install_Value* new_this; | 1361 new_this->type = STRING_VALUE; |
1410 » new_this = (Pk11Install_Value*)PR_Malloc(sizeof(Pk11Install_Value)); | 1362 new_this->string = NULL; |
1411 » new_this->type = STRING_VALUE; | 1363 new_this->pair = NULL; |
1412 » new_this->string = NULL; | 1364 new_this->next = NULL; |
1413 » new_this->pair = NULL; | 1365 return new_this; |
1414 » new_this->next = NULL; | |
1415 » return new_this; | |
1416 } | 1366 } |
1417 | 1367 |
1418 /****************************************************************************/ | 1368 /****************************************************************************/ |
1419 Pk11Install_Value* | 1369 Pk11Install_Value *Pk11Install_Value_new(ValueType _type, |
1420 Pk11Install_Value_new(ValueType _type, Pk11Install_Pointer ptr) | 1370 Pk11Install_Pointer ptr) { |
1421 { | 1371 Pk11Install_Value *new_this; |
1422 » Pk11Install_Value* new_this; | 1372 new_this = Pk11Install_Value_new_default(); |
1423 » new_this = Pk11Install_Value_new_default(); | 1373 new_this->type = _type; |
1424 » new_this->type = _type; | 1374 if (_type == STRING_VALUE) { |
1425 » if(_type == STRING_VALUE) { | 1375 new_this->pair = NULL; |
1426 » » new_this->pair = NULL; | 1376 new_this->string = ptr.string; |
1427 » » new_this->string = ptr.string; | 1377 } else { |
1428 » } else { | 1378 new_this->string = NULL; |
1429 » » new_this->string = NULL; | 1379 new_this->pair = ptr.pair; |
1430 » » new_this->pair = ptr.pair; | 1380 } |
1431 » } | 1381 return new_this; |
1432 » return new_this; | |
1433 } | 1382 } |
1434 | 1383 |
1435 /****************************************************************************/ | 1384 /****************************************************************************/ |
1436 void | 1385 void Pk11Install_Value_delete(Pk11Install_Value *_this) { |
1437 Pk11Install_Value_delete(Pk11Install_Value* _this) | 1386 if (_this->type == STRING_VALUE) { |
1438 { | 1387 PR_Free(_this->string); |
1439 » if(_this->type == STRING_VALUE) { | 1388 } else { |
1440 » » PR_Free(_this->string); | 1389 PR_Free(_this->pair); |
1441 » } else { | 1390 } |
1442 » » PR_Free(_this->pair); | |
1443 » } | |
1444 } | 1391 } |
1445 | 1392 |
1446 /****************************************************************************/ | 1393 /****************************************************************************/ |
1447 Pk11Install_Pair* | 1394 Pk11Install_Pair *Pk11Install_Pair_new_default() { |
1448 Pk11Install_Pair_new_default() | 1395 return Pk11Install_Pair_new(NULL, NULL); |
1449 { | |
1450 » return Pk11Install_Pair_new(NULL,NULL); | |
1451 } | 1396 } |
1452 | 1397 |
1453 /****************************************************************************/ | 1398 /****************************************************************************/ |
1454 Pk11Install_Pair* | 1399 Pk11Install_Pair *Pk11Install_Pair_new(char *_key, |
1455 Pk11Install_Pair_new(char *_key, Pk11Install_ValueList *_list) | 1400 Pk11Install_ValueList *_list) { |
1456 { | 1401 Pk11Install_Pair *new_this; |
1457 » Pk11Install_Pair* new_this; | 1402 new_this = (Pk11Install_Pair *)PR_Malloc(sizeof(Pk11Install_Pair)); |
1458 » new_this = (Pk11Install_Pair*)PR_Malloc(sizeof(Pk11Install_Pair)); | 1403 new_this->key = _key; |
1459 » new_this->key = _key; | 1404 new_this->list = _list; |
1460 » new_this->list = _list; | 1405 return new_this; |
1461 » return new_this; | |
1462 } | 1406 } |
1463 | 1407 |
1464 /****************************************************************************/ | 1408 /****************************************************************************/ |
1465 void | 1409 void Pk11Install_Pair_delete(Pk11Install_Pair *_this) { |
1466 Pk11Install_Pair_delete(Pk11Install_Pair* _this) | 1410 PR_Free(_this->key); |
1467 { | 1411 Pk11Install_ValueList_delete(_this->list); |
1468 » PR_Free(_this->key); | 1412 PR_Free(_this->list); |
1469 » Pk11Install_ValueList_delete(_this->list); | |
1470 » PR_Free(_this->list); | |
1471 } | 1413 } |
1472 | 1414 |
1473 /*************************************************************************/ | 1415 /*************************************************************************/ |
1474 void | 1416 void Pk11Install_Pair_Print(Pk11Install_Pair *_this, int pad) { |
1475 Pk11Install_Pair_Print(Pk11Install_Pair* _this, int pad) | 1417 while (_this) { |
1476 { | 1418 /*PAD(pad); printf("**Pair\n"); |
1477 » while (_this) { | 1419 PAD(pad); printf("***Key====\n");*/ |
1478 » » /*PAD(pad); printf("**Pair\n"); | 1420 PAD(pad); |
1479 » » PAD(pad); printf("***Key====\n");*/ | 1421 printf("%s {\n", _this->key); |
1480 » » PAD(pad); printf("%s {\n", _this->key); | 1422 /*PAD(pad); printf("====\n");*/ |
1481 » » /*PAD(pad); printf("====\n");*/ | 1423 /*PAD(pad); printf("***ValueList\n");*/ |
1482 » » /*PAD(pad); printf("***ValueList\n");*/ | 1424 Pk11Install_ValueList_Print(_this->list, pad + PADINC); |
1483 » » Pk11Install_ValueList_Print(_this->list,pad+PADINC); | 1425 PAD(pad); |
1484 » » PAD(pad); printf("}\n"); | 1426 printf("}\n"); |
1485 » } | 1427 } |
1486 } | 1428 } |
1487 | 1429 |
1488 /*************************************************************************/ | 1430 /*************************************************************************/ |
1489 void | 1431 void Pk11Install_ValueList_Print(Pk11Install_ValueList *_this, int pad) { |
1490 Pk11Install_ValueList_Print(Pk11Install_ValueList* _this, int pad) | 1432 Pk11Install_Value *v; |
1491 { | 1433 |
1492 » Pk11Install_Value *v; | 1434 /*PAD(pad);printf("**Value List**\n");*/ |
1493 | 1435 for (v = _this->head; v != NULL; v = v->next) { |
1494 » /*PAD(pad);printf("**Value List**\n");*/ | 1436 Pk11Install_Value_Print(v, pad); |
1495 » for(v = _this->head; v != NULL; v=v->next) { | 1437 } |
1496 » » Pk11Install_Value_Print(v,pad); | |
1497 » } | |
1498 } | 1438 } |
1499 | 1439 |
1500 /*************************************************************************/ | 1440 /*************************************************************************/ |
1501 void | 1441 void Pk11Install_Value_Print(Pk11Install_Value *_this, int pad) { |
1502 Pk11Install_Value_Print(Pk11Install_Value* _this, int pad) | 1442 /*PAD(pad); printf("**Value, type=%s\n", |
1503 { | 1443 type==STRING_VALUE ? "string" : "pair");*/ |
1504 » /*PAD(pad); printf("**Value, type=%s\n", | 1444 if (_this->type == STRING_VALUE) { |
1505 » » type==STRING_VALUE ? "string" : "pair");*/ | 1445 /*PAD(pad+PADINC); printf("====\n");*/ |
1506 » if(_this->type==STRING_VALUE) { | 1446 PAD(pad); |
1507 » » /*PAD(pad+PADINC); printf("====\n");*/ | 1447 printf("%s\n", _this->string); |
1508 » » PAD(pad); printf("%s\n", _this->string); | 1448 /*PAD(pad+PADINC); printf("====\n");*/ |
1509 » » /*PAD(pad+PADINC); printf("====\n");*/ | 1449 } else { |
1510 » } else { | 1450 Pk11Install_Pair_Print(_this->pair, pad + PADINC); |
1511 » » Pk11Install_Pair_Print(_this->pair,pad+PADINC); | 1451 } |
1512 » } | 1452 } |
1513 } | |
OLD | NEW |