void OUTPUT_FORMATTER::object_key_value(const char *key, const char *key_fmt, const char *value, const char *value_fmt, int wrap) { POOL_MEM string; POOL_MEM wvalue(value); rewrap(wvalue, wrap); switch (api) { #if HAVE_JANSSON case API_MODE_JSON: json_key_value_add(key, wvalue.c_str()); break; #endif default: if (key_fmt) { string.bsprintf(key_fmt, key); result_message_plain->strcat(string); } if (value_fmt) { string.bsprintf(value_fmt, wvalue.c_str()); result_message_plain->strcat(string); } Dmsg2(800, "obj: %s:%s\n", key, wvalue.c_str()); } }
PRBool GRE_GetPathFromRegKey(HKEY aRegKey, const GREVersionRange *versions, PRUint32 versionsLength, const GREProperty *properties, PRUint32 propertiesLength, char* aBuffer, PRUint32 aBufLen) { // Formerly, GREs were registered at the registry key // HKLM/Software/mozilla.org/GRE/<version> valuepair GreHome=Path. // Nowadays, they are registered in any subkey of // Software/mozilla.org/GRE, with the following valuepairs: // Version=<version> (REG_SZ) // GreHome=<path> (REG_SZ or REG_EXPAND_SZ) // <Property>=<value> (REG_SZ) // // Additional meta-info may be available in the future, including // localization info and other information which might be pertinent // to selecting one GRE over another. // // When a GRE is being registered, it should try to register itself at // HKLM/Software/mozilla.org/GRE/<Version> first, to preserve compatibility // with older glue. If this key is already taken (i.e. there is more than // one GRE of that version installed), it should append a unique number to // the version, for example: // 1.1 (already in use), 1.1_1, 1.1_2, etc... DWORD i = 0; PRUnichar buffer[MAXPATHLEN + 1]; while (PR_TRUE) { PRUnichar name[MAXPATHLEN + 1]; DWORD nameLen = MAXPATHLEN; if (::RegEnumKeyExW(aRegKey, i, name, &nameLen, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) { break; } HKEY subKey = NULL; if (::RegOpenKeyExW(aRegKey, name, 0, KEY_QUERY_VALUE, &subKey) != ERROR_SUCCESS) { continue; } PRUnichar version[40]; DWORD versionlen = 40; PRUnichar pathbuf[MAXPATHLEN + 1]; DWORD pathlen; DWORD pathtype; PRBool ok = PR_FALSE; if (::RegQueryValueExW(subKey, L"Version", NULL, NULL, (BYTE*) version, &versionlen) == ERROR_SUCCESS && CheckVersion(version, versions, versionsLength)) { ok = PR_TRUE; const GREProperty *props = properties; const GREProperty *propsEnd = properties + propertiesLength; for (; ok && props < propsEnd; ++props) { pathlen = MAXPATHLEN + 1; AutoWString wproperty(ConvertUTF8toNewUTF16(props->property)); AutoWString wvalue(ConvertUTF8toNewUTF16(props->value)); if (::RegQueryValueExW(subKey, wproperty, NULL, &pathtype, (BYTE*) pathbuf, &pathlen) != ERROR_SUCCESS || wcscmp(pathbuf, wvalue)) ok = PR_FALSE; } pathlen = sizeof(pathbuf); if (ok && (!::RegQueryValueExW(subKey, L"GreHome", NULL, &pathtype, (BYTE*) pathbuf, &pathlen) == ERROR_SUCCESS || !*pathbuf || !CopyWithEnvExpansion(buffer, pathbuf, MAXPATHLEN, pathtype))) { ok = PR_FALSE; } else if (!wcsncat(buffer, L"\\" LXPCOM_DLL, aBufLen) #ifdef WINCE || (GetFileAttributesW(buffer) == INVALID_FILE_ATTRIBUTES) #else || _waccess(buffer, R_OK) #endif ) { ok = PR_FALSE; } } RegCloseKey(subKey); if (ok) { WideCharToMultiByte(CP_UTF8, 0, buffer, -1, aBuffer, aBufLen, NULL, NULL); return PR_TRUE; } ++i; } aBuffer[0] = '\0'; return PR_FALSE; }