|
Lines 27-38
Link Here
|
| 27 |
int filter(const struct dirent *dir) |
27 |
int filter(const struct dirent *dir) |
| 28 |
{ |
28 |
{ |
| 29 |
char* prefixes[] = { |
29 |
char* prefixes[] = { |
| 30 |
"xulrunner-", |
30 |
"xulrunner\0", |
| 31 |
"mozilla-seamonkey-", |
31 |
"xulrunner-1", |
| 32 |
"seamonkey-", |
32 |
"mozilla-seamonkey-1", |
| 33 |
"mozilla-", |
33 |
"seamonkey-1", |
| 34 |
"mozilla-firefox-", |
34 |
"mozilla-1", |
| 35 |
"firefox-", |
35 |
"mozilla-firefox-2", |
|
|
36 |
"firefox-2", |
| 37 |
"mozilla-firefox-3", |
| 38 |
"firefox-3", |
| 36 |
NULL |
39 |
NULL |
| 37 |
}; |
40 |
}; |
| 38 |
int XULRUNNER_INDEX = 0; |
41 |
int XULRUNNER_INDEX = 0; |
|
Lines 63-91
Link Here
|
| 63 |
int prefixLength = strlen(prefix); |
66 |
int prefixLength = strlen(prefix); |
| 64 |
if (strncmp(dirname, prefix, prefixLength) == 0) |
67 |
if (strncmp(dirname, prefix, prefixLength) == 0) |
| 65 |
{ |
68 |
{ |
|
|
69 |
/* If a xulrunner install is found then success is immediate since |
| 70 |
* xulrunner always provides an embeddable GRE. |
| 71 |
*/ |
| 66 |
if (index == XULRUNNER_INDEX) return 1; /* include in scandir result */ |
72 |
if (index == XULRUNNER_INDEX) return 1; /* include in scandir result */ |
| 67 |
|
73 |
|
| 68 |
/* Check if the first character following the prefix is a numeric digit. |
|
|
| 69 |
* This ensures that the suffix represents a version number like |
| 70 |
* "mozilla-1.7.3", and not a different product like "mozilla-thunderbird". |
| 71 |
*/ |
| 72 |
int dirLength = strlen(dirname); |
74 |
int dirLength = strlen(dirname); |
| 73 |
if ('0' <= dirname[prefixLength] && dirname[prefixLength] <= '9') { |
75 |
char* testpath = malloc (strlen(root) + dirLength + strlen(testlib) + 1); |
| 74 |
/* If a xulrunner install is found then success is immediate since |
76 |
strcpy(testpath, root); |
| 75 |
* xulrunner always provides an embeddable GRE. |
77 |
strcat(testpath, dirname); |
| 76 |
*/ |
78 |
strcat(testpath, testlib); |
| 77 |
if (index == XULRUNNER_INDEX) return 1; /* include in scandir result */ |
79 |
int success = stat(testpath, &buf) == 0; |
| 78 |
|
80 |
free(testpath); |
| 79 |
char* testpath = malloc (strlen(root) + dirLength + strlen(testlib) + 1); |
81 |
if (success) |
| 80 |
strcpy(testpath, root); |
82 |
{ |
| 81 |
strcat(testpath, dirname); |
83 |
return 1; /* include in scandir result */ |
| 82 |
strcat(testpath, testlib); |
|
|
| 83 |
int success = stat(testpath, &buf) == 0; |
| 84 |
free(testpath); |
| 85 |
if (success) |
| 86 |
{ |
| 87 |
return 1; /* include in scandir result */ |
| 88 |
} |
| 89 |
} |
84 |
} |
| 90 |
} |
85 |
} |
| 91 |
prefix = prefixes [++index]; |
86 |
prefix = prefixes [++index]; |
|
Lines 202-208
Link Here
|
| 202 |
/* Try some common installation locations. */ |
197 |
/* Try some common installation locations. */ |
| 203 |
if (grePath == NULL) |
198 |
if (grePath == NULL) |
| 204 |
{ |
199 |
{ |
| 205 |
/* try xulrunner-*, mozilla-*, firefox-* directories in /usr/lib/ */ |
200 |
/* try xulrunner-1*, mozilla-1*, firefox-2/3*, seamonkey-1* directories in /usr/lib/ */ |
| 206 |
#if defined(__amd64__) || defined(__x86_64__) || defined(__powerpc64__) |
201 |
#if defined(__amd64__) || defined(__x86_64__) || defined(__powerpc64__) |
| 207 |
char* dir = "/usr/lib64/"; |
202 |
char* dir = "/usr/lib64/"; |
| 208 |
#else |
203 |
#else |
|
Lines 217-224
Link Here
|
| 217 |
int count = scandir(dir, &namelist, filter, alphasort); |
212 |
int count = scandir(dir, &namelist, filter, alphasort); |
| 218 |
if (count > 0) |
213 |
if (count > 0) |
| 219 |
{ |
214 |
{ |
| 220 |
/* count-1 is used below in an attempt to get the matched directory |
215 |
/* count-1 is used below in an attempt to choose XULRunner |
| 221 |
* with the latest version number. |
216 |
* any time one is found |
| 222 |
*/ |
217 |
*/ |
| 223 |
char* name = namelist [count - 1]->d_name; |
218 |
char* name = namelist [count - 1]->d_name; |
| 224 |
#endif |
219 |
#endif |
|
Lines 310-320
Link Here
|
| 310 |
|
305 |
|
| 311 |
if (grePath != NULL) |
306 |
if (grePath != NULL) |
| 312 |
{ |
307 |
{ |
| 313 |
ldPath = (char*)realloc(ldPath, strlen(ldPath) + strlen(grePath) + 2); |
308 |
/* If grePath contains "xul" then do not change the LD_LIBRARY_PATH, |
| 314 |
if (strlen(ldPath) > 0) strcat(ldPath, ":"); |
309 |
* since it is likely that a xulrunner (not a mozilla or firefox) |
| 315 |
strcat(ldPath, grePath); |
310 |
* will be found at runtime. Note that MOZILLA_FIVE_HOME is still |
| 316 |
setenv("LD_LIBRARY_PATH", ldPath, 1); |
311 |
* updated if grePath contains "xul" since this variable can act as |
| 317 |
|
312 |
* a backup GRE to try if an initially-detected one fails to load. |
|
|
313 |
*/ |
| 314 |
char* current = strrchr(grePath, 'x'); |
| 315 |
if (current == NULL || strncmp(current, "xul", 3) != 0) { |
| 316 |
ldPath = (char*)realloc(ldPath, strlen(ldPath) + strlen(grePath) + 2); |
| 317 |
if (strlen(ldPath) > 0) strcat(ldPath, ":"); |
| 318 |
strcat(ldPath, grePath); |
| 319 |
setenv("LD_LIBRARY_PATH", ldPath, 1); |
| 320 |
} |
| 321 |
|
| 318 |
if (mozillaFiveHome == NULL) setenv("MOZILLA_FIVE_HOME", grePath, 1); |
322 |
if (mozillaFiveHome == NULL) setenv("MOZILLA_FIVE_HOME", grePath, 1); |
| 319 |
free(grePath); |
323 |
free(grePath); |
| 320 |
} |
324 |
} |