CFURLCreateCopyAppendingPathComponent(NULL, fwurl, CFSTR("XUL"), PR_TRUE);
CFURLCreateCopyAppendingPathComponent(NULL, absfwurl, CFSTR("XUL.framework"), PR_TRUE);
GRE_GetGREPathForVersion(const char *aVersion,                         char *aBuffer, PRUint32 aBufLen){  // if GRE_HOME is in the environment, use that GRE  const char* env = getenv("GRE_HOME");  if (env && *env) {#if XP_UNIX    if (realpath(env, aBuffer))      return NS_OK;#elif XP_WIN    if (_fullpath(aBuffer, env, aBufLen))      return NS_OK;#else    // hope for the best    // xxxbsmedberg: other platforms should have a "make absolute" function#endif    if (strlen(env) >= aBufLen)      return NS_ERROR_FILE_NAME_TOO_LONG;    strcpy(aBuffer, env);    return NS_OK;  }  // the Gecko bits that sit next to the application or in the LD_LIBRARY_PATH  env = getenv("USE_LOCAL_GRE");  if (env && *env) {    *aBuffer = nsnull;    return NS_OK;  }#ifdef XP_MACOSX  aBuffer[0] = '\0';  // Check the bundle first, for <bundle>/Contents/Frameworks/XUL/libxpcom.dylib  CFBundleRef appBundle = CFBundleGetMainBundle();  if (appBundle) {    CFURLRef fwurl = CFBundleCopyPrivateFrameworksURL(appBundle);    if (fwurl) {      CFURLRef xulurl =        CFURLCreateCopyAppendingPathComponent(NULL, fwurl,                                              CFSTR("XUL"), PR_TRUE);      if (xulurl) {        CFURLRef xpcomurl =          CFURLCreateCopyAppendingPathComponent(NULL, xulurl,                                                CFSTR("libxpcom.dylib"),                                                PR_FALSE);        if (xpcomurl) {          if (!CFURLGetFileSystemRepresentation(xpcomurl, PR_TRUE,                                               (UInt8*) aBuffer, aBufLen) ||              access(aBuffer, R_OK | X_OK) != 0)            aBuffer[0] = '\0';        }        CFRelease(xulurl);      }      CFRelease(fwurl);    }  }  if (aBuffer[0])    return NS_OK;  // Check ~/Library/Frameworks/XUL/Versions/<version>/libxpcom.dylib  const char *home = getenv("HOME");  if (home && *home && GRE_FindGREFramework(aVersion, home, aBuffer, aBufLen)) {    return NS_OK;  }  // Check /Library/Frameworks/XUL/Versions/<version>/libxpcom.dylib  if (GRE_FindGREFramework(aVersion, "", aBuffer, aBufLen)) {    return NS_OK;  }#elif defined(XP_UNIX)   env = getenv("MOZ_GRE_CONF");  if (env && GRE_GetPathFromConfigFile(aVersion, env, aBuffer, aBufLen)) {    return NS_OK;  }  env = getenv("HOME");  if (env && *env) {    char buffer[MAXPATHLEN];    // Look in ~/.gre.config    snprintf(buffer, sizeof(buffer),             "%s" XPCOM_FILE_PATH_SEPARATOR GRE_CONF_NAME, env);        if (GRE_GetPathFromConfigFile(aVersion, buffer, aBuffer, aBufLen)) {      return NS_OK;    }    // Look in ~/.gre.d/*.conf    snprintf(buffer, sizeof(buffer),             "%s" XPCOM_FILE_PATH_SEPARATOR GRE_USER_CONF_DIR, env);    if (GRE_GetPathFromConfigDir(aVersion, buffer, aBuffer, aBufLen)) {      return NS_OK;    }  }  // Look for a global /etc/gre.conf file  if (GRE_GetPathFromConfigFile(aVersion, GRE_CONF_PATH, aBuffer, aBufLen)) {    return NS_OK;  }  // Look for a group of config files in /etc/gre.d/  if (GRE_GetPathFromConfigDir(aVersion, GRE_CONF_DIR, aBuffer, aBufLen)) {    return NS_OK;  }#elif defined(XP_WIN)  HKEY hRegKey = NULL;      // A couple of key points here:  // 1. Note the usage of the "Software\\Mozilla\\GRE" subkey - this allows  //    us to have multiple versions of GREs on the same machine by having  //    subkeys such as 1.0, 1.1, 2.0 etc. under it.  // 2. In this sample below we're looking for the location of GRE version 1.2  //    i.e. we're compatible with GRE 1.2 and we're trying to find it's install  //    location.  //  // Please see http://www.mozilla.org/projects/embedding/GRE.html for  // more info.  //  if (::RegOpenKeyEx(HKEY_CURRENT_USER, GRE_WIN_REG_LOC, 0,                     KEY_READ, &hRegKey) == ERROR_SUCCESS) {    PRBool ok = GRE_GetPathFromRegKey(aVersion, hRegKey, aBuffer, aBufLen);    ::RegCloseKey(hRegKey);    if (ok)      return NS_OK;  }  if (::RegOpenKeyEx(HKEY_LOCAL_MACHINE, GRE_WIN_REG_LOC, 0,                     KEY_ENUMERATE_SUB_KEYS, &hRegKey) == ERROR_SUCCESS) {    PRBool ok = GRE_GetPathFromRegKey(aVersion, hRegKey, aBuffer, aBufLen);    ::RegCloseKey(hRegKey);    if (ok)      return NS_OK;  }#endif  return NS_ERROR_FAILURE;}