本文整理汇总了C++中PR_GetEnv函数的典型用法代码示例。如果您正苦于以下问题:C++ PR_GetEnv函数的具体用法?C++ PR_GetEnv怎么用?C++ PR_GetEnv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PR_GetEnv函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: CSFLogDebug
/**
* Peforms intialization of the MANDATORY components of the Video Engine
*/
MediaConduitErrorCode WebrtcVideoConduit::Init()
{
CSFLogDebug(logTag, "%s ", __FUNCTION__);
#ifdef MOZ_WIDGET_ANDROID
jobject context = jsjni_GetGlobalContextRef();
// get the JVM
JavaVM *jvm = jsjni_GetVM();
JNIEnv* env;
if (jvm->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK) {
CSFLogError(logTag, "%s: could not get Java environment", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
jvm->AttachCurrentThread(&env, nullptr);
if (webrtc::VideoEngine::SetAndroidObjects(jvm, (void*)context) != 0) {
CSFLogError(logTag, "%s: could not set Android objects", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
env->DeleteGlobalRef(context);
#endif
if( !(mVideoEngine = webrtc::VideoEngine::Create()) )
{
CSFLogError(logTag, "%s Unable to create video engine ", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
PRLogModuleInfo *logs = GetWebRTCLogInfo();
if (!gWebrtcTraceLoggingOn && logs && logs->level > 0) {
// no need to a critical section or lock here
gWebrtcTraceLoggingOn = 1;
const char *file = PR_GetEnv("WEBRTC_TRACE_FILE");
if (!file) {
file = "WebRTC.log";
}
CSFLogDebug(logTag, "%s Logging webrtc to %s level %d", __FUNCTION__,
file, logs->level);
mVideoEngine->SetTraceFilter(logs->level);
mVideoEngine->SetTraceFile(file);
}
if( !(mPtrViEBase = ViEBase::GetInterface(mVideoEngine)))
{
CSFLogError(logTag, "%s Unable to get video base interface ", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
if( !(mPtrViECapture = ViECapture::GetInterface(mVideoEngine)))
{
CSFLogError(logTag, "%s Unable to get video capture interface", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
if( !(mPtrViECodec = ViECodec::GetInterface(mVideoEngine)))
{
CSFLogError(logTag, "%s Unable to get video codec interface ", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
if( !(mPtrViENetwork = ViENetwork::GetInterface(mVideoEngine)))
{
CSFLogError(logTag, "%s Unable to get video network interface ", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
if( !(mPtrViERender = ViERender::GetInterface(mVideoEngine)))
{
CSFLogError(logTag, "%s Unable to get video render interface ", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
if( !(mPtrRTP = webrtc::ViERTP_RTCP::GetInterface(mVideoEngine)))
{
CSFLogError(logTag, "%s Unable to get video RTCP interface ", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
CSFLogDebug(logTag, "%s Engine Created: Init'ng the interfaces ",__FUNCTION__);
if(mPtrViEBase->Init() == -1)
{
CSFLogError(logTag, " %s Video Engine Init Failed %d ",__FUNCTION__,
mPtrViEBase->LastError());
return kMediaConduitSessionNotInited;
}
if(mPtrViEBase->CreateChannel(mChannel) == -1)
{
CSFLogError(logTag, " %s Channel creation Failed %d ",__FUNCTION__,
mPtrViEBase->LastError());
//.........这里部分代码省略.........
开发者ID:birtles,项目名称:mozilla-central,代码行数:101,代码来源:VideoConduit.cpp
示例2: _PR_InitLog
void _PR_InitLog(void)
{
char *ev;
_pr_logLock = PR_NewLock();
ev = PR_GetEnv("NSPR_LOG_MODULES");
if (ev && ev[0]) {
char module[64]; /* Security-Critical: If you change this
* size, you must also change the sscanf
* format string to be size-1.
*/
PRBool isSync = PR_FALSE;
PRIntn evlen = strlen(ev), pos = 0;
PRInt32 bufSize = DEFAULT_BUF_SIZE;
while (pos < evlen) {
PRIntn level = 1, count = 0, delta = 0;
count = sscanf(&ev[pos], "%63[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-]%n:%d%n",
module, &delta, &level, &delta);
pos += delta;
if (count == 0) break;
/*
** If count == 2, then we got module and level. If count
** == 1, then level defaults to 1 (module enabled).
*/
if (strcasecmp(module, "sync") == 0) {
isSync = PR_TRUE;
} else if (strcasecmp(module, "bufsize") == 0) {
if (level >= LINE_BUF_SIZE) {
bufSize = level;
}
} else if (strcasecmp(module, "timestamp") == 0) {
outputTimeStamp = PR_TRUE;
} else if (strcasecmp(module, "append") == 0) {
appendToLog = PR_TRUE;
} else {
PRLogModuleInfo *lm = logModules;
PRBool skip_modcheck =
(0 == strcasecmp (module, "all")) ? PR_TRUE : PR_FALSE;
while (lm != NULL) {
if (skip_modcheck) lm -> level = (PRLogModuleLevel)level;
else if (strcasecmp(module, lm->name) == 0) {
lm->level = (PRLogModuleLevel)level;
break;
}
lm = lm->next;
}
}
/*found:*/
count = sscanf(&ev[pos], " , %n", &delta);
pos += delta;
if (count == EOF) break;
}
PR_SetLogBuffering(isSync ? 0 : bufSize);
#ifdef XP_UNIX
if ((getuid() != geteuid()) || (getgid() != getegid())) {
return;
}
#endif /* XP_UNIX */
ev = PR_GetEnv("NSPR_LOG_FILE");
if (ev && ev[0]) {
if (!PR_SetLogFile(ev)) {
#ifdef XP_PC
char* str = PR_smprintf("Unable to create nspr log file '%s'\n", ev);
if (str) {
OutputDebugStringA(str);
PR_smprintf_free(str);
}
#else
fprintf(stderr, "Unable to create nspr log file '%s'\n", ev);
#endif
}
} else {
#ifdef _PR_USE_STDIO_FOR_LOGGING
logFile = stderr;
#else
logFile = _pr_stderr;
#endif
}
}
}
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:85,代码来源:prlog.c
示例3: ShouldA11yBeEnabled
bool
ShouldA11yBeEnabled()
{
static bool sChecked = false, sShouldEnable = false;
if (sChecked)
return sShouldEnable;
sChecked = true;
EPlatformDisabledState disabledState = PlatformDisabledState();
if (disabledState == ePlatformIsDisabled)
return sShouldEnable = false;
// check if accessibility enabled/disabled by environment variable
const char* envValue = PR_GetEnv(sAccEnv);
if (envValue)
return sShouldEnable = !!atoi(envValue);
#ifdef MOZ_ENABLE_DBUS
PreInit();
bool dbusSuccess = false;
DBusMessage *reply = nullptr;
if (!sPendingCall)
goto dbus_done;
dbus_pending_call_block(sPendingCall);
reply = dbus_pending_call_steal_reply(sPendingCall);
dbus_pending_call_unref(sPendingCall);
sPendingCall = nullptr;
if (!reply ||
dbus_message_get_type(reply) != DBUS_MESSAGE_TYPE_METHOD_RETURN ||
strcmp(dbus_message_get_signature (reply), DBUS_TYPE_VARIANT_AS_STRING))
goto dbus_done;
DBusMessageIter iter, iter_variant, iter_struct;
dbus_bool_t dResult;
dbus_message_iter_init(reply, &iter);
dbus_message_iter_recurse (&iter, &iter_variant);
switch (dbus_message_iter_get_arg_type(&iter_variant)) {
case DBUS_TYPE_STRUCT:
// at-spi2-core 2.2.0-2.2.1 had a bug where it returned a struct
dbus_message_iter_recurse(&iter_variant, &iter_struct);
if (dbus_message_iter_get_arg_type(&iter_struct) == DBUS_TYPE_BOOLEAN) {
dbus_message_iter_get_basic(&iter_struct, &dResult);
sShouldEnable = dResult;
dbusSuccess = true;
}
break;
case DBUS_TYPE_BOOLEAN:
dbus_message_iter_get_basic(&iter_variant, &dResult);
sShouldEnable = dResult;
dbusSuccess = true;
break;
default:
break;
}
dbus_done:
if (reply)
dbus_message_unref(reply);
if (dbusSuccess)
return sShouldEnable;
#endif
//check gconf-2 setting
static const char sGconfAccessibilityKey[] =
"/desktop/gnome/interface/accessibility";
nsresult rv = NS_OK;
nsCOMPtr<nsIGConfService> gconf =
do_GetService(NS_GCONFSERVICE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && gconf)
gconf->GetBool(NS_LITERAL_CSTRING(sGconfAccessibilityKey), &sShouldEnable);
return sShouldEnable;
}
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:77,代码来源:ApplicationAccessibleWrap.cpp
示例4: CSFLogDebug
/**
* Peforms intialization of the MANDATORY components of the Video Engine
*/
MediaConduitErrorCode WebrtcVideoConduit::Init(WebrtcVideoConduit *other)
{
CSFLogDebug(logTag, "%s this=%p other=%p", __FUNCTION__, this, other);
if (other) {
MOZ_ASSERT(!other->mOtherDirection);
other->mOtherDirection = this;
mOtherDirection = other;
// only one can call ::Create()/GetVideoEngine()
MOZ_ASSERT(other->mVideoEngine);
mVideoEngine = other->mVideoEngine;
} else {
#ifdef MOZ_WIDGET_ANDROID
jobject context = jsjni_GetGlobalContextRef();
// get the JVM
JavaVM *jvm = jsjni_GetVM();
if (webrtc::VideoEngine::SetAndroidObjects(jvm, (void*)context) != 0) {
CSFLogError(logTag, "%s: could not set Android objects", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
#endif
// Per WebRTC APIs below function calls return nullptr on failure
if( !(mVideoEngine = webrtc::VideoEngine::Create()) )
{
CSFLogError(logTag, "%s Unable to create video engine ", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
PRLogModuleInfo *logs = GetWebRTCLogInfo();
if (!gWebrtcTraceLoggingOn && logs && logs->level > 0) {
// no need to a critical section or lock here
gWebrtcTraceLoggingOn = 1;
const char *file = PR_GetEnv("WEBRTC_TRACE_FILE");
if (!file) {
file = "WebRTC.log";
}
CSFLogDebug(logTag, "%s Logging webrtc to %s level %d", __FUNCTION__,
file, logs->level);
mVideoEngine->SetTraceFilter(logs->level);
mVideoEngine->SetTraceFile(file);
}
}
if( !(mPtrViEBase = ViEBase::GetInterface(mVideoEngine)))
{
CSFLogError(logTag, "%s Unable to get video base interface ", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
if( !(mPtrViECapture = ViECapture::GetInterface(mVideoEngine)))
{
CSFLogError(logTag, "%s Unable to get video capture interface", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
if( !(mPtrViECodec = ViECodec::GetInterface(mVideoEngine)))
{
CSFLogError(logTag, "%s Unable to get video codec interface ", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
if( !(mPtrViENetwork = ViENetwork::GetInterface(mVideoEngine)))
{
CSFLogError(logTag, "%s Unable to get video network interface ", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
if( !(mPtrViERender = ViERender::GetInterface(mVideoEngine)))
{
CSFLogError(logTag, "%s Unable to get video render interface ", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
if( !(mPtrRTP = webrtc::ViERTP_RTCP::GetInterface(mVideoEngine)))
{
CSFLogError(logTag, "%s Unable to get video RTCP interface ", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
if ( !(mPtrExtCodec = webrtc::ViEExternalCodec::GetInterface(mVideoEngine)))
{
CSFLogError(logTag, "%s Unable to get external codec interface %d ",
__FUNCTION__, mPtrViEBase->LastError());
return kMediaConduitSessionNotInited;
}
if (other) {
mChannel = other->mChannel;
mPtrExtCapture = other->mPtrExtCapture;
mCapId = other->mCapId;
} else {
//.........这里部分代码省略.........
开发者ID:cbrem,项目名称:gecko-dev,代码行数:101,代码来源:VideoConduit.cpp
示例5: CSFLogDebug
/*
* WebRTCAudioConduit Implementation
*/
MediaConduitErrorCode WebrtcAudioConduit::Init(WebrtcAudioConduit *other)
{
CSFLogDebug(logTag, "%s this=%p other=%p", __FUNCTION__, this, other);
if (other) {
MOZ_ASSERT(!other->mOtherDirection);
other->mOtherDirection = this;
mOtherDirection = other;
// only one can call ::Create()/GetVoiceEngine()
MOZ_ASSERT(other->mVoiceEngine);
mVoiceEngine = other->mVoiceEngine;
} else {
#ifdef MOZ_WIDGET_ANDROID
jobject context = jsjni_GetGlobalContextRef();
// get the JVM
JavaVM *jvm = jsjni_GetVM();
JNIEnv* env;
if (jvm->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK) {
CSFLogError(logTag, "%s: could not get Java environment", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
jvm->AttachCurrentThread(&env, NULL);
if (webrtc::VoiceEngine::SetAndroidObjects(jvm, (void*)context) != 0) {
CSFLogError(logTag, "%s Unable to set Android objects", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
env->DeleteGlobalRef(context);
#endif
//Per WebRTC APIs below function calls return NULL on failure
if(!(mVoiceEngine = webrtc::VoiceEngine::Create()))
{
CSFLogError(logTag, "%s Unable to create voice engine", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
PRLogModuleInfo *logs = GetWebRTCLogInfo();
if (!gWebrtcTraceLoggingOn && logs && logs->level > 0) {
// no need to a critical section or lock here
gWebrtcTraceLoggingOn = 1;
const char *file = PR_GetEnv("WEBRTC_TRACE_FILE");
if (!file) {
file = "WebRTC.log";
}
CSFLogDebug(logTag, "%s Logging webrtc to %s level %d", __FUNCTION__,
file, logs->level);
mVoiceEngine->SetTraceFilter(logs->level);
mVoiceEngine->SetTraceFile(file);
}
}
if(!(mPtrVoEBase = VoEBase::GetInterface(mVoiceEngine)))
{
CSFLogError(logTag, "%s Unable to initialize VoEBase", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
if(!(mPtrVoENetwork = VoENetwork::GetInterface(mVoiceEngine)))
{
CSFLogError(logTag, "%s Unable to initialize VoENetwork", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
if(!(mPtrVoECodec = VoECodec::GetInterface(mVoiceEngine)))
{
CSFLogError(logTag, "%s Unable to initialize VoEBCodec", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
if(!(mPtrVoEProcessing = VoEAudioProcessing::GetInterface(mVoiceEngine)))
{
CSFLogError(logTag, "%s Unable to initialize VoEProcessing", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
if(!(mPtrVoEXmedia = VoEExternalMedia::GetInterface(mVoiceEngine)))
{
CSFLogError(logTag, "%s Unable to initialize VoEExternalMedia", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
if (other) {
mChannel = other->mChannel;
} else {
// init the engine with our audio device layer
if(mPtrVoEBase->Init() == -1)
{
CSFLogError(logTag, "%s VoiceEngine Base Not Initialized", __FUNCTION__);
return kMediaConduitSessionNotInited;
}
//.........这里部分代码省略.........
开发者ID:RickEyre,项目名称:mozilla-central,代码行数:101,代码来源:AudioConduit.cpp
示例6: MOZ_ASSERT
void
nsPicoService::Init()
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(!mInitialized);
if (!sPicoApi.Init()) {
NS_WARNING("Failed to initialize pico library");
return;
}
// Use environment variable, or default android path
nsAutoCString langPath(PR_GetEnv("PICO_LANG_PATH"));
if (langPath.IsEmpty()) {
langPath.AssignLiteral(PICO_LANG_PATH);
}
nsCOMPtr<nsIFile> voicesDir;
NS_NewNativeLocalFile(langPath, true, getter_AddRefs(voicesDir));
nsCOMPtr<nsISimpleEnumerator> dirIterator;
nsresult rv = voicesDir->GetDirectoryEntries(getter_AddRefs(dirIterator));
if (NS_FAILED(rv)) {
NS_WARNING(nsPrintfCString("Failed to get contents of directory: %s", langPath.get()).get());
return;
}
bool hasMoreElements = false;
rv = dirIterator->HasMoreElements(&hasMoreElements);
MOZ_ASSERT(NS_SUCCEEDED(rv));
MonitorAutoLock autoLock(mVoicesMonitor);
while (hasMoreElements && NS_SUCCEEDED(rv)) {
nsCOMPtr<nsISupports> supports;
rv = dirIterator->GetNext(getter_AddRefs(supports));
MOZ_ASSERT(NS_SUCCEEDED(rv));
nsCOMPtr<nsIFile> voiceFile = do_QueryInterface(supports);
MOZ_ASSERT(voiceFile);
nsAutoCString leafName;
voiceFile->GetNativeLeafName(leafName);
nsAutoString lang;
if (GetVoiceFileLanguage(leafName, lang)) {
nsAutoString uri;
uri.AssignLiteral("urn:moz-tts:pico:");
uri.Append(lang);
bool found = false;
PicoVoice* voice = mVoices.GetWeak(uri, &found);
if (!found) {
voice = new PicoVoice(lang);
mVoices.Put(uri, voice);
}
// Each voice consists of two lingware files: A language resource file,
// suffixed by _ta.bin, and a speaker resource file, suffixed by _sb.bin.
// We currently assume that there is a pair of files for each language.
if (StringEndsWith(leafName, NS_LITERAL_CSTRING("_ta.bin"))) {
rv = voiceFile->GetPersistentDescriptor(voice->mTaFile);
MOZ_ASSERT(NS_SUCCEEDED(rv));
} else if (StringEndsWith(leafName, NS_LITERAL_CSTRING("_sg.bin"))) {
rv = voiceFile->GetPersistentDescriptor(voice->mSgFile);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
}
rv = dirIterator->HasMoreElements(&hasMoreElements);
}
NS_DispatchToMainThread(NewRunnableMethod("nsPicoService::RegisterVoices",
this, &nsPicoService::RegisterVoices));
}
开发者ID:bgrins,项目名称:gecko-dev,代码行数:79,代码来源:nsPicoService.cpp
示例7: test_validatechain_NB
int test_validatechain_NB(int argc, char *argv[]){
PKIX_ValidateParams *valParams = NULL;
PKIX_ValidateResult *valResult = NULL;
PKIX_UInt32 actualMinorVersion;
PKIX_UInt32 j = 0;
PKIX_UInt32 k = 0;
PKIX_UInt32 chainLength = 0;
PKIX_Boolean testValid = PKIX_TRUE;
PKIX_List *chainCerts = NULL;
PKIX_PL_Cert *dirCert = NULL;
char *dirCertName = NULL;
char *anchorCertName = NULL;
char *dirName = NULL;
PKIX_UInt32 certIndex = 0;
PKIX_UInt32 anchorIndex = 0;
PKIX_UInt32 checkerIndex = 0;
PKIX_Boolean revChecking = PKIX_FALSE;
PKIX_List *checkers = NULL;
PRPollDesc *pollDesc = NULL;
PRErrorCode errorCode = 0;
PKIX_PL_Socket *socket = NULL;
char *ldapName = NULL;
PKIX_VerifyNode *verifyTree = NULL;
PKIX_PL_String *verifyString = NULL;
PKIX_List *loggers = NULL;
PKIX_Logger *logger = NULL;
char *logging = NULL;
PKIX_PL_String *component = NULL;
PKIX_TEST_STD_VARS();
if (argc < 5) {
printUsage();
return (0);
}
startTests("ValidateChain_NB");
PKIX_TEST_EXPECT_NO_ERROR(
PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
/* ENE = expect no error; EE = expect error */
if (PORT_Strcmp(argv[2+j], "ENE") == 0) {
testValid = PKIX_TRUE;
} else if (PORT_Strcmp(argv[2+j], "EE") == 0) {
testValid = PKIX_FALSE;
} else {
printUsage();
return (0);
}
subTest(argv[1+j]);
dirName = argv[3+j];
chainLength = argc - j - 5;
PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_Create(&chainCerts, plContext));
for (k = 0; k < chainLength; k++){
dirCert = createCert(dirName, argv[5+k+j], plContext);
PKIX_TEST_EXPECT_NO_ERROR
(PKIX_List_AppendItem
(chainCerts, (PKIX_PL_Object *)dirCert, plContext));
PKIX_TEST_DECREF_BC(dirCert);
}
valParams = createValidateParams
(dirName,
argv[4+j],
NULL,
NULL,
NULL,
PKIX_FALSE,
PKIX_FALSE,
PKIX_FALSE,
PKIX_FALSE,
chainCerts,
plContext);
ldapName = PR_GetEnv("LDAP");
/* Is LDAP set in the environment? */
if ((ldapName == NULL) || (*ldapName == '\0')) {
testError("LDAP not set in environment");
goto cleanup;
}
pkixTestErrorResult = pkix_pl_Socket_CreateByName
(PKIX_FALSE, /* isServer */
PR_SecondsToInterval(30), /* try 30 secs for connect */
ldapName,
&errorCode,
&socket,
plContext);
//.........这里部分代码省略.........
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:101,代码来源:test_validatechain_NB.c
示例8: StartServer
int
StartServer(const char *nssCertDBDir, SSLSNISocketConfig sniSocketConfig,
void *sniSocketConfigArg)
{
const char *debugLevel = PR_GetEnv("MOZ_TLS_SERVER_DEBUG_LEVEL");
if (debugLevel) {
int level = atoi(debugLevel);
switch (level) {
case DEBUG_ERRORS: gDebugLevel = DEBUG_ERRORS; break;
case DEBUG_WARNINGS: gDebugLevel = DEBUG_WARNINGS; break;
case DEBUG_VERBOSE: gDebugLevel = DEBUG_VERBOSE; break;
default:
PrintPRError("invalid MOZ_TLS_SERVER_DEBUG_LEVEL");
return 1;
}
}
const char *callbackPort = PR_GetEnv("MOZ_TLS_SERVER_CALLBACK_PORT");
if (callbackPort) {
gCallbackPort = atoi(callbackPort);
}
if (InitializeNSS(nssCertDBDir) != SECSuccess) {
PR_fprintf(PR_STDERR, "InitializeNSS failed");
return 1;
}
if (NSS_SetDomesticPolicy() != SECSuccess) {
PrintPRError("NSS_SetDomesticPolicy failed");
return 1;
}
if (SSL_ConfigServerSessionIDCache(0, 0, 0, nullptr) != SECSuccess) {
PrintPRError("SSL_ConfigServerSessionIDCache failed");
return 1;
}
UniquePRFileDesc serverSocket(PR_NewTCPSocket());
if (!serverSocket) {
PrintPRError("PR_NewTCPSocket failed");
return 1;
}
PRSocketOptionData socketOption;
socketOption.option = PR_SockOpt_Reuseaddr;
socketOption.value.reuse_addr = true;
PR_SetSocketOption(serverSocket.get(), &socketOption);
PRNetAddr serverAddr;
PR_InitializeNetAddr(PR_IpAddrLoopback, LISTEN_PORT, &serverAddr);
if (PR_Bind(serverSocket.get(), &serverAddr) != PR_SUCCESS) {
PrintPRError("PR_Bind failed");
return 1;
}
if (PR_Listen(serverSocket.get(), 1) != PR_SUCCESS) {
PrintPRError("PR_Listen failed");
return 1;
}
UniquePRFileDesc rawModelSocket(PR_NewTCPSocket());
if (!rawModelSocket) {
PrintPRError("PR_NewTCPSocket failed for rawModelSocket");
return 1;
}
UniquePRFileDesc modelSocket(SSL_ImportFD(nullptr, rawModelSocket.release()));
if (!modelSocket) {
PrintPRError("SSL_ImportFD of rawModelSocket failed");
return 1;
}
if (SSL_SNISocketConfigHook(modelSocket.get(), sniSocketConfig,
sniSocketConfigArg) != SECSuccess) {
PrintPRError("SSL_SNISocketConfigHook failed");
return 1;
}
// We have to configure the server with a certificate, but it's not one
// we're actually going to end up using. In the SNI callback, we pick
// the right certificate for the connection.
if (ConfigSecureServerWithNamedCert(modelSocket.get(), DEFAULT_CERT_NICKNAME,
nullptr, nullptr) != SECSuccess) {
return 1;
}
if (gCallbackPort != 0) {
if (DoCallback()) {
return 1;
}
}
while (true) {
PRNetAddr clientAddr;
PRFileDesc* clientSocket = PR_Accept(serverSocket.get(), &clientAddr,
PR_INTERVAL_NO_TIMEOUT);
HandleConnection(clientSocket, modelSocket);
}
return 0;
//.........这里部分代码省略.........
开发者ID:leplatrem,项目名称:gecko-dev,代码行数:101,代码来源:TLSServer.cpp
示例9: defined
//----------------------------------------------------------------------------------------
// GetProductDirectory - Gets the directory which contains the application data folder
//
// UNIX : ~/.mozilla/
// WIN : <Application Data folder on user's machine>\Mozilla
// Mac : :Documents:Mozilla:
//----------------------------------------------------------------------------------------
NS_METHOD
nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
bool aLocal)
{
if (NS_WARN_IF(!aLocalFile)) {
return NS_ERROR_INVALID_ARG;
}
nsresult rv;
bool exists;
nsCOMPtr<nsIFile> localDir;
#if defined(MOZ_WIDGET_COCOA)
FSRef fsRef;
OSType folderType = aLocal ? (OSType)kCachedDataFolderType :
(OSType)kDomainLibraryFolderType;
OSErr err = ::FSFindFolder(kUserDomain, folderType, kCreateFolder, &fsRef);
if (err) {
return NS_ERROR_FAILURE;
}
NS_NewLocalFile(EmptyString(), true, getter_AddRefs(localDir));
if (!localDir) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsILocalFileMac> localDirMac(do_QueryInterface(localDir));
rv = localDirMac->InitWithFSRef(&fsRef);
if (NS_FAILED(rv)) {
return rv;
}
#elif defined(XP_WIN)
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
return rv;
}
const char* prop = aLocal ? NS_WIN_LOCAL_APPDATA_DIR : NS_WIN_APPDATA_DIR;
rv = directoryService->Get(prop, NS_GET_IID(nsIFile), getter_AddRefs(localDir));
if (NS_FAILED(rv)) {
return rv;
}
#elif defined(XP_UNIX)
rv = NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), true,
getter_AddRefs(localDir));
if (NS_FAILED(rv)) {
return rv;
}
#else
#error dont_know_how_to_get_product_dir_on_your_platform
#endif
rv = localDir->AppendRelativeNativePath(DEFAULT_PRODUCT_DIR);
if (NS_FAILED(rv)) {
return rv;
}
rv = localDir->Exists(&exists);
if (NS_SUCCEEDED(rv) && !exists) {
rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
}
if (NS_FAILED(rv)) {
return rv;
}
localDir.forget(aLocalFile);
return rv;
}
开发者ID:MekliCZ,项目名称:positron,代码行数:75,代码来源:nsAppFileLocationProvider.cpp
示例10: GetSpecialSystemDirectory
nsresult
GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
nsIFile** aFile)
{
#if defined(XP_WIN)
WCHAR path[MAX_PATH];
#else
char path[MAXPATHLEN];
#endif
switch (aSystemSystemDirectory)
{
case OS_CurrentWorkingDirectory:
#if defined(XP_WIN)
if (!_wgetcwd(path, MAX_PATH))
return NS_ERROR_FAILURE;
return NS_NewLocalFile(nsDependentString(path),
true,
aFile);
#else
if(!getcwd(path, MAXPATHLEN))
return NS_ERROR_FAILURE;
#endif
#if !defined(XP_WIN)
return NS_NewNativeLocalFile(nsDependentCString(path),
true,
aFile);
#endif
case OS_DriveDirectory:
#if defined (XP_WIN)
{
int32_t len = ::GetWindowsDirectoryW(path, MAX_PATH);
if (len == 0)
break;
if (path[1] == PRUnichar(':') && path[2] == PRUnichar('\\'))
path[3] = 0;
return NS_NewLocalFile(nsDependentString(path),
true,
aFile);
}
#else
return NS_NewNativeLocalFile(nsDependentCString("/"),
true,
aFile);
#endif
case OS_TemporaryDirectory:
#if defined (XP_WIN)
{
DWORD len = ::GetTempPathW(MAX_PATH, path);
if (len == 0)
break;
return NS_NewLocalFile(nsDependentString(path, len),
true,
aFile);
}
#elif defined(MOZ_WIDGET_COCOA)
{
return GetOSXFolderType(kUserDomain, kTemporaryFolderType, aFile);
}
#elif defined(XP_UNIX)
{
static const char *tPath = nullptr;
if (!tPath) {
tPath = PR_GetEnv("PANDORATMP");
if (!tPath) {
tPath = PR_GetEnv("TMPDIR");
if (!tPath || !*tPath) {
tPath = PR_GetEnv("TMP");
if (!tPath || !*tPath) {
tPath = PR_GetEnv("TEMP");
if (!tPath || !*tPath) {
tPath = "/tmp/";
}
}
}
}
}
return NS_NewNativeLocalFile(nsDependentCString(tPath),
true,
aFile);
}
#else
break;
#endif
#if defined (XP_WIN)
case Win_SystemDirectory:
{
int32_t len = ::GetSystemDirectoryW(path, MAX_PATH);
// Need enough space to add the trailing backslash
if (!len || len > MAX_PATH - 2)
break;
path[len] = L'\\';
path[++len] = L'\0';
//.........这里部分代码省略.........
开发者ID:dimag0g,项目名称:Pale-Moon,代码行数:101,代码来源:SpecialSystemDirectory.cpp
示例11: ShutdownXPCOM
//.........这里部分代码省略.........
// Release the directory service
nsDirectoryService::gService = nullptr;
free(gGREBinPath);
gGREBinPath = nullptr;
if (moduleLoaders) {
bool more;
nsCOMPtr<nsISupports> el;
while (NS_SUCCEEDED(moduleLoaders->HasMoreElements(&more)) && more) {
moduleLoaders->GetNext(getter_AddRefs(el));
// Don't worry about weak-reference observers here: there is
// no reason for weak-ref observers to register for
// xpcom-shutdown-loaders
// FIXME: This can cause harmless writes from sqlite committing
// log files. We have to ignore them before we can move
// the mozilla::PoisonWrite call before this point. See bug
// 834945 for the details.
nsCOMPtr<nsIObserver> obs(do_QueryInterface(el));
if (obs) {
obs->Observe(nullptr, NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID, nullptr);
}
}
moduleLoaders = nullptr;
}
bool shutdownCollect;
#ifdef NS_FREE_PERMANENT_DATA
shutdownCollect = true;
#else
shutdownCollect = !!PR_GetEnv("MOZ_CC_RUN_DURING_SHUTDOWN");
#endif
nsCycleCollector_shutdown(shutdownCollect);
PROFILER_MARKER("Shutdown xpcom");
// If we are doing any shutdown checks, poison writes.
if (gShutdownChecks != SCM_NOTHING) {
#ifdef XP_MACOSX
mozilla::OnlyReportDirtyWrites();
#endif /* XP_MACOSX */
mozilla::BeginLateWriteChecks();
}
// Shutdown nsLocalFile string conversion
NS_ShutdownLocalFile();
#ifdef XP_UNIX
NS_ShutdownNativeCharsetUtils();
#endif
// Shutdown xpcom. This will release all loaders and cause others holding
// a refcount to the component manager to release it.
if (nsComponentManagerImpl::gComponentManager) {
rv = (nsComponentManagerImpl::gComponentManager)->Shutdown();
NS_ASSERTION(NS_SUCCEEDED(rv), "Component Manager shutdown failed.");
} else {
NS_WARNING("Component Manager was never created ...");
}
#ifdef MOZ_ENABLE_PROFILER_SPS
// In optimized builds we don't do shutdown collections by default, so
// uncollected (garbage) objects may keep the nsXPConnect singleton alive,
// and its XPCJSRuntime along with it. However, we still destroy various
// bits of state in JS_ShutDown(), so we need to make sure the profiler
开发者ID:cliqz-oss,项目名称:browser-f,代码行数:67,代码来源:XPCOMInit.cpp
示例12: GetUnixXDGUserDirectory
static nsresult
GetUnixXDGUserDirectory(SystemDirectories aSystemDirectory,
nsIFile** aFile)
{
char *dir = xdg_user_dir_lookup
(xdg_user_dirs + xdg_user_dir_offsets[aSystemDirectory -
Unix_XDG_Desktop]);
nsresult rv;
nsCOMPtr<nsIFile> file;
if (dir) {
rv = NS_NewNativeLocalFile(nsDependentCString(dir), true,
getter_AddRefs(file));
free(dir);
} else if (Unix_XDG_Desktop == aSystemDirectory) {
// for the XDG desktop dir, fall back to HOME/Desktop
// (for historical compatibility)
rv = GetUnixHomeDir(getter_AddRefs(file));
if (NS_FAILED(rv))
return rv;
rv = file->AppendNative(NS_LITERAL_CSTRING("Desktop"));
}
#if defined(MOZ_PLATFORM_MAEMO)
// "MYDOCSDIR" is exported to point to "/home/user/MyDocs" in maemo.
else if (Unix_XDG_Documents == aSystemDirectory) {
char *myDocs = PR_GetEnv("MYDOCSDIR");
if (!myDocs || !*myDocs)
return NS_ERROR_FAILURE;
rv = NS_NewNativeLocalFile(nsDependentCString(myDocs), true,
getter_AddRefs(file));
if (NS_FAILED(rv))
return rv;
rv = file->AppendNative(NS_LITERAL_CSTRING(".documents"));
}
#endif
else {
// no fallback for the other XDG dirs
rv = NS_ERROR_FAILURE;
}
if (NS_FAILED(rv))
return rv;
bool exists;
rv = file->Exists(&exists);
if (NS_FAILED(rv))
return rv;
if (!exists) {
rv = file->Create(nsIFile::DIRECTORY_TYPE, 0755);
if (NS_FAILED(rv))
return rv;
}
*aFile = nullptr;
file.swap(*aFile);
return NS_OK;
}
开发者ID:dimag0g,项目名称:Pale-Moon,代码行数:62,代码来源:SpecialSystemDirectory.cpp
示例13: read
void
GfxInfo::GetData()
{
// to understand this function, see bug 639842. We retrieve the OpenGL driver information in a
// separate process to protect against bad drivers.
// if glxtest_pipe == 0, that means that we already read the information
if (!glxtest_pipe)
return;
enum { buf_size = 1024 };
char buf[buf_size];
ssize_t bytesread = read(glxtest_pipe,
&buf,
buf_size-1); // -1 because we'll append a zero
close(glxtest_pipe);
glxtest_pipe = 0;
// bytesread < 0 would mean that the above read() call failed. This should never happen.
if (bytesread < 0)
bytesread = 0;
// let buf be a zero-terminated string
buf[bytesread] = 0;
// Wait for the glxtest process to finish. This serves 2 purposes:
// * avoid having a zombie glxtest process laying around
// * get the glxtest process status info.
int glxtest_status = 0;
bool wait_for_glxtest_process = true;
bool waiting_for_glxtest_process_failed = false;
while(wait_for_glxtest_process) {
wait_for_glxtest_process = false;
if (waitpid(glxtest_pid, &glxtest_status, 0) == -1) {
if (errno == EINTR)
wait_for_glxtest_process = true;
else
waiting_for_glxtest_process_failed = true;
}
}
bool exited_with_error_code = !waiting_for_glxtest_process_failed &&
WIFEXITED(glxtest_status) &&
WEXITSTATUS(glxtest_status) != EXIT_SUCCESS;
bool received_signal = !waiting_for_glxtest_process_failed &&
WIFSIGNALED(glxtest_status);
bool error = waiting_for_glxtest_process_failed || exited_with_error_code || received_signal;
nsCString *stringToFill = nsnull;
char *bufptr = buf;
if (!error) {
while(true) {
char *line = NS_strtok("\n", &bufptr);
if (!line)
break;
if (stringToFill) {
stringToFill->Assign(line);
stringToFill = nsnull;
}
else if(!strcmp(line, "VENDOR"))
stringToFill = &mVendor;
else if(!strcmp(line, "RENDERER"))
stringToFill = &mRenderer;
else if(!strcmp(line, "VERSION"))
stringToFill = &mVersion;
}
}
const char *spoofedVendor = PR_GetEnv("MOZ_GFX_SPOOF_GL_VENDOR");
if (spoofedVendor)
mVendor.Assign(spoofedVendor);
const char *spoofedRenderer = PR_GetEnv("MOZ_GFX_SPOOF_GL_RENDERER");
if (spoofedRenderer)
mRenderer.Assign(spoofedRenderer);
const char *spoofedVersion = PR_GetEnv("MOZ_GFX_SPOOF_GL_VERSION");
if (spoofedVersion)
mVersion.Assign(spoofedVersion);
if (error ||
mVendor.IsEmpty() ||
mRenderer.IsEmpty() ||
mVersion.IsEmpty())
{
mAdapterDescription.AppendLiteral("GLXtest process failed");
if (waiting_for_glxtest_process_failed)
mAdapterDescription.AppendLiteral(" (waitpid failed)");
if (exited_with_error_code)
mAdapterDescription.AppendPrintf(" (exited with status %d)", WEXITSTATUS(glxtest_status));
if (received_signal)
mAdapterDescription.AppendPrintf(" (received signal %d)", WTERMSIG(glxtest_status));
if (bytesread) {
mAdapterDescription.AppendLiteral(": ");
mAdapterDescription.Append(nsDependentCString(buf));
mAdapterDescription.AppendLiteral("\n");
}
#ifdef MOZ_CRASHREPORTER
CrashReporter::AppendAppNotesToCrashReport(mAdapterDescription);
#endif
return;
//.........这里部分代码省略.........
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:101,代码来源:GfxInfoX11.cpp
示例14: WriteConsoleLog
void
WriteConsoleLog()
{
nsresult rv;
nsCOMPtr<nsILocalFile> lfile;
char* logFileEnv = PR_GetEnv("XRE_CONSOLE_LOG");
if (logFileEnv && *logFileEnv) {
rv = XRE_GetFileFromPath(logFileEnv, getter_AddRefs(lfile));
if (NS_FAILED(rv))
return;
}
else {
if (!gLogConsoleErrors)
return;
rv = gDirServiceProvider->GetUserAppDataDirectory(getter_AddRefs(lfile));
if (NS_FAILED(rv))
return;
lfile->AppendNative(NS_LITERAL_CSTRING("console.log"));
}
PRFileDesc *file;
rv = lfile->OpenNSPRFileDesc(PR_WRONLY | PR_APPEND | PR_CREATE_FILE,
0660, &file);
if (NS_FAILED(rv))
return;
nsCOMPtr<nsIConsoleService> csrv
(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
if (!csrv) {
PR_Close(file);
return;
}
nsIConsoleMessage** messages;
PRUint32 mcount;
rv = csrv->GetMessageArray(&messages, &mcount);
if (NS_FAILED(rv)) {
PR_Close(file);
return;
}
if (mcount) {
PRExplodedTime etime;
PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &etime);
char datetime[512];
PR_FormatTimeUSEnglish(datetime, sizeof(datetime),
"%Y-%m-%d %H:%M:%S", &etime);
PR_fprintf(file, NS_LINEBREAK
"*** Console log: %s ***" NS_LINEBREAK,
datetime);
}
// From this point on, we have to release all the messages, and free
// the memory allocated for the messages array. XPCOM arrays suck.
nsXPIDLString msg;
nsCAutoString nativemsg;
for (PRUint32 i = 0; i < mcount; ++i) {
rv = messages[i]->GetMessage(getter_Copies(msg));
if (NS_SUCCEEDED(rv)) {
NS_CopyUnicodeToNative(msg, nativemsg);
PR_fprintf(file, "%s" NS_LINEBREAK, nativemsg.get());
}
NS_IF_RELEASE(messages[i]);
}
PR_Close(file);
NS_Free(messages);
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:76,代码来源:nsConsoleWriter.cpp
示例15: GetProductDirectory
NS_IMETHODIMP
nsAppFileLocationProvider::GetFile(const char* aProp, bool* aPersistent,
nsIFile** aResult)
{
if (NS_WARN_IF(!aProp)) {
return NS_ERROR_INVALID_ARG;
}
nsCOMPtr<nsIFile> localFile;
nsresult rv = NS_ERROR_FAILURE;
*aResult = nullptr;
*aPersistent = true;
#ifdef MOZ_WIDGET_COCOA
FSRef fileRef;
nsCOMPtr<nsILocalFileMac> macFile;
#endif
if (nsCRT::strcmp(aProp, NS_APP_APPLICATION_REGISTRY_DIR) == 0) {
rv = GetProductDirectory(getter_AddRefs(localFile));
} else if (nsCRT::strcmp(aProp, NS_APP_APPLICATION_REGISTRY_FILE) == 0) {
rv = GetProductDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendNative(APP_REGISTRY_NAME);
}
} else if (nsCRT::strcmp(aProp, NS_APP_DEFAULTS_50_DIR) == 0) {
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME);
}
} else if (nsCRT::strcmp(aProp, NS_APP_PREF_DEFAULTS_50_DIR) == 0) {
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME);
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativeNativePath(DEFAULTS_PREF_DIR_NAME);
}
}
} else if (nsCRT::strcmp(aProp, NS_APP_USER_PROFILES_ROOT_DIR) == 0) {
rv = GetDefaultUserProfileRoot(getter_AddRefs(localFile));
} else if (nsCRT::strcmp(aProp, NS_APP_USER_PROFILES_LOCAL_ROOT_DIR) == 0) {
rv = GetDefaultUserProfileRoot(getter_AddRefs(localFile), true);
} else if (nsCRT::strcmp(aProp, NS_APP_RES_DIR) == 0) {
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativeNativePath(RES_DIR_NAME);
}
} else if (nsCRT::strcmp(aProp, NS_APP_CHROME_DIR) == 0) {
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativeNativePath(CHROME_DIR_NAME);
}
} else if (nsCRT::strcmp(aProp, NS_APP_PLUGINS_DIR) == 0) {
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME);
}
}
#ifdef MOZ_WIDGET_COCOA
else if (nsCRT::strcmp(aProp, NS_MACOSX_USER_PLUGIN_DIR) == 0) {
if (::FSFindFolder(kUserDomain, kInternetPlugInFolderType, false,
&fileRef) == noErr) {
rv = NS_NewLocalFileWithFSRef(&fileRef, true, getter_AddRefs(macFile));
if (NS_SUCCEEDED(rv)) {
localFile = macFile;
}
}
} else if (nsCRT::strcmp(aProp, NS_MACOSX_LOCAL_PLUGIN_DIR) == 0) {
if (::FSFindFolder(kLocalDomain, kInternetPlugInFolderType, false,
&fileRef) == noErr) {
rv = NS_NewLocalFileWithFSRef(&fileRef, true, getter_AddRefs(macFile));
if (NS_SUCCEEDED(rv)) {
localFile = macFile;
}
}
} else if (nsCRT::strcmp(aProp, NS_MACOSX_JAVA2_PLUGIN_DIR) == 0) {
static const char* const java2PluginDirPath =
"/System/Library/Java/Support/Deploy.bundle/Contents/Resources/";
rv = NS_NewNativeLocalFile(nsDependentCString(java2PluginDirPath), true,
getter_AddRefs(localFile));
}
#else
else
|
请发表评论