这篇教程C++ ssh函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ssh函数的典型用法代码示例。如果您正苦于以下问题:C++ ssh函数的具体用法?C++ ssh怎么用?C++ ssh使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了ssh函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: sshvoid SFTPWorkerThread::DoConnect(SFTPThreadRequet* req){ wxString accountName = req->GetAccount().GetAccountName(); clSSH::Ptr_t ssh(new clSSH(req->GetAccount().GetHost(), req->GetAccount().GetUsername(), req->GetAccount().GetPassword(), req->GetAccount().GetPort())); try { wxString message; DoReportStatusBarMessage(wxString() << _("Connecting to ") << accountName); DoReportMessage(accountName, "Connecting...", SFTPThreadMessage::STATUS_NONE); ssh->Connect(); if(!ssh->AuthenticateServer(message)) { ssh->AcceptServerAuthentication(); } ssh->Login(); m_sftp.reset(new clSFTP(ssh)); // associate the account with the connection m_sftp->SetAccount(req->GetAccount().GetAccountName()); m_sftp->Initialize(); wxString msg; msg << "Successfully connected to " << accountName; DoReportMessage(accountName, msg, SFTPThreadMessage::STATUS_OK); } catch(clException& e) { wxString msg; msg << "Connect error. " << e.What(); DoReportMessage(accountName, msg, SFTPThreadMessage::STATUS_ERROR); m_sftp.reset(NULL); }}
开发者ID:srini2174,项目名称:codelite,代码行数:34,
示例2: registrchar *proobraz(char* input){input = registr(input);input= ficha(input);for (int i=0;i<strlen(input);i++) { ssin(i,input); ccos(i,input); aasin(i,input); aacos(i,input); aatan(i,input); cceil(i,input); cch(i,input); eexp(i,input); aabs(i,input); ffloor(i,input); lln(i,input); llog(i,input); ssh(i,input); ssqrt(i,input); ttan(i,input); tth(i,input); cctg(i,input); aactg(i,input); ccth(i,input); } return input;}
开发者ID:spellanser,项目名称:graphx,代码行数:29,
示例3: sshvoid HxCPDSpatialGraphWarp::applyRigidDeformationToSliceVanMises( SpatialGraphSelection& slice, HxSpatialGraph* spatialGraph, const ma::CPDLinearAligner& deformation, const McDMatrix<double>& R, const double s, const McDVector<double>& t) { McWatch watch; watch.start(); ma::SliceSelector ssh(spatialGraph, "TransformInfo"); SpatialGraphSelection fullSliceSelection; ssh.getSlice(ssh.getSliceAttributeValueFromIndex(1), fullSliceSelection); for (int i = 0; i < fullSliceSelection.getNumSelectedEdges(); i++) { int edge = fullSliceSelection.getSelectedEdge(i); McDArray<McVec3f> newEdgePoints; for (int j = 0; j < spatialGraph->getNumEdgePoints(edge); j++) { McVec3f edgePoint = spatialGraph->getEdgePoint(edge, j); const McVec3f edgePointWarped = deformation.warpPoint(edgePoint, R, s, t); newEdgePoints.append(edgePointWarped); } spatialGraph->setEdgePoints(edge, newEdgePoints); } for (int i = 0; i < fullSliceSelection.getNumSelectedVertices(); i++) { int curVertex = fullSliceSelection.getSelectedVertex(i); McVec3f curCoord = spatialGraph->getVertexCoords(curVertex); const McVec3f curCoordWarped = deformation.warpPoint(curCoord, R, s, t); spatialGraph->setVertexCoords(curVertex, curCoordWarped); } std::cout << "/n Apply deformation took " << watch.stop() << " seconds.";}
开发者ID:zibamira,项目名称:microtubulestitching,代码行数:35,
示例4: sshvoid BaseExecutionContext::onShutdownPostSend() { ServerStats::SetThreadMode(ServerStats::PostProcessing); try { try { ServerStatsHelper ssh("psp", ServerStatsHelper::TRACK_HWINST); if (!m_shutdowns.isNull()) { if (m_shutdowns.exists(PostSend)) { executeFunctions(m_shutdowns[PostSend]); m_shutdowns.remove(PostSend); } if (m_shutdowns.exists(CleanUp)) { executeFunctions(m_shutdowns[CleanUp]); m_shutdowns.remove(CleanUp); } } } catch (const ExitException &e) { // do nothing } catch (const Exception &e) { onFatalError(e); } catch (const Object &e) { onUnhandledException(e); } } catch (...) { Logger::Error("unknown exception was thrown from psp"); } ServerStats::SetThreadMode(ServerStats::Idling);}
开发者ID:Bathrisyah,项目名称:hiphop-php,代码行数:27,
示例5: assertvoid Transport::sendRawLocked(void *data, int size, int code /* = 200 */, bool compressed /* = false */, bool chunked /* = false */, const char *codeInfo /* = "" */ ) { if (!compressed && RuntimeOption::ForceChunkedEncoding) { chunked = true; } if (m_chunkedEncoding) { chunked = true; assert(!compressed); } else if (chunked) { m_chunkedEncoding = true; assert(!compressed); } // I don't think there is any need to send an empty chunk, other than sending // out headers earlier, which seems to be a useless feature. if (chunked && size == 0) { return; } if (!m_headerCallbackDone && !m_headerCallback.isNull()) { // We could use m_headerSent here, however it seems we can still // end up in an infinite loop when: // m_headerCallback calls flush() // flush() triggers php's recursion guard // the recursion guard calls back into m_headerCallback m_headerCallbackDone = true; vm_call_user_func(m_headerCallback, null_array); } // compression handling ServerStatsHelper ssh("send"); String response = prepareResponse(data, size, compressed, !chunked); if (m_responseCode < 0) { m_responseCode = code; m_responseCodeInfo = codeInfo ? codeInfo: ""; } // HTTP header handling if (!m_headerSent) { String orig_response((const char *)data, size, CopyString); prepareHeaders(compressed, chunked, response, orig_response); m_headerSent = true; } m_responseSize += response.size(); ServerStats::SetThreadMode(ServerStats::ThreadMode::Writing); sendImpl(response.data(), response.size(), m_responseCode, chunked); ServerStats::SetThreadMode(ServerStats::ThreadMode::Processing); ServerStats::LogBytes(size); if (RuntimeOption::EnableStats && RuntimeOption::EnableWebStats) { ServerStats::Log("network.uncompressed", size); ServerStats::Log("network.compressed", response.size()); }}
开发者ID:IMGM,项目名称:hiphop-php,代码行数:59,
示例6: TESTTEST(signal, sigqueue) { ScopedSignalHandler ssh(SIGALRM, SigqueueSignalHandler, SA_SIGINFO); sigval_t sigval; sigval.sival_int = 1; errno = 0; ASSERT_EQ(0, sigqueue(getpid(), SIGALRM, sigval)); ASSERT_EQ(0, errno); ASSERT_EQ(1, g_sigqueue_signal_handler_call_count);}
开发者ID:RUIXUEZHAOFENGNIAN,项目名称:platform_bionic,代码行数:9,
示例7: TESTTEST(spawn, signal_stress) { // Ensure that posix_spawn doesn't restore the caller's signal mask in the // child without first defaulting any caught signals (http://b/68707996). static pid_t parent = getpid(); setpgid(0, 0); signal(SIGRTMIN, SIG_IGN); pid_t pid = fork(); ASSERT_NE(-1, pid); if (pid == 0) { for (size_t i = 0; i < 1024; ++i) { kill(0, SIGRTMIN); usleep(10); } _exit(99); } // We test both with and without attributes, because they used to be // different codepaths. We also test with an empty `sigdefault` set. posix_spawnattr_t attr1; posix_spawnattr_init(&attr1); sigset_t empty_mask = {}; posix_spawnattr_t attr2; posix_spawnattr_init(&attr2); posix_spawnattr_setflags(&attr2, POSIX_SPAWN_SETSIGDEF); posix_spawnattr_setsigdefault(&attr2, &empty_mask); posix_spawnattr_t* attrs[] = { nullptr, &attr1, &attr2 }; // We use a real-time signal because that's a tricky case for LP32 // because our sigset_t was too small. ScopedSignalHandler ssh(SIGRTMIN, [](int) { ASSERT_EQ(getpid(), parent); }); const size_t pid_count = 128; pid_t spawned_pids[pid_count]; ExecTestHelper eth; eth.SetArgs({"true", nullptr}); for (size_t i = 0; i < pid_count; ++i) { pid_t spawned_pid; ASSERT_EQ(0, posix_spawn(&spawned_pid, "true", nullptr, attrs[i % 3], eth.GetArgs(), nullptr)); spawned_pids[i] = spawned_pid; } for (pid_t spawned_pid : spawned_pids) { ASSERT_EQ(spawned_pid, TEMP_FAILURE_RETRY(waitpid(spawned_pid, nullptr, 0))); } AssertChildExited(pid, 99);}
开发者ID:android,项目名称:platform_bionic,代码行数:53,
示例8: epvoid RPCRequestHandler::handleRequest(Transport *transport) { ExecutionProfiler ep(ThreadInfo::RuntimeFunctions); Logger::OnNewRequest(); m_context->setTransport(transport); transport->enableCompression(); ServerStatsHelper ssh("all", true); Logger::Verbose("receiving %s", transport->getCommand().c_str()); // will clear all extra logging when this function goes out of scope StackTraceNoHeap::ExtraLoggingClearer clearer; StackTraceNoHeap::AddExtraLogging("RPC-URL", transport->getUrl()); // authentication const string &password = m_serverInfo->getPassword(); if (!password.empty() && password != transport->getParam("auth")) { transport->sendString("Unauthorized", 401); transport->onSendEnd(); return; } // resolve virtual host const VirtualHost *vhost = HttpProtocol::GetVirtualHost(transport); ASSERT(vhost); if (vhost->disabled()) { transport->sendString("Virtual host disabled.", 404); transport->onSendEnd(); return; } vhost->setRequestTimeoutSeconds(); // resolve source root string host = transport->getHeader("Host"); SourceRootInfo sourceRootInfo(host.c_str()); // set thread type switch (m_serverInfo->getType()) { case SatelliteServer::KindOfRPCServer: transport->setThreadType(Transport::RpcThread); break; case SatelliteServer::KindOfXboxServer: transport->setThreadType(Transport::XboxThread); break; default: break; } // record request for debugging purpose std::string tmpfile = HttpProtocol::RecordRequest(transport); bool ret = executePHPFunction(transport, sourceRootInfo); HttpProtocol::ClearRecord(ret, tmpfile);}
开发者ID:Jostein,项目名称:hiphop-php,代码行数:53,
示例9: ASSERTvoid Transport::sendRaw(void *data, int size, int code /* = 200 */, bool compressed /* = false */, bool chunked /* = false */, const char *codeInfo /* = "" */ ) { ASSERT(data || size == 0); ASSERT(size >= 0); FiberWriteLock lock(this); if (!compressed && RuntimeOption::ForceChunkedEncoding) { chunked = true; } if (m_chunkedEncoding) { chunked = true; ASSERT(!compressed); } else if (chunked) { m_chunkedEncoding = true; ASSERT(!compressed); } // I don't think there is any need to send an empty chunk, other than sending // out headers earlier, which seems to be a useless feature. if (chunked && size == 0) { return; } // compression handling ServerStatsHelper ssh("send"); String response = prepareResponse(data, size, compressed, !chunked); if (m_responseCode < 0) { m_responseCode = code; m_responseCodeInfo = codeInfo ? codeInfo: ""; } // HTTP header handling if (!m_headerSent) { prepareHeaders(compressed, data, size); m_headerSent = true; } m_responseSize += response.size(); ServerStats::SetThreadMode(ServerStats::Writing); sendImpl(response.data(), response.size(), m_responseCode, chunked); ServerStats::SetThreadMode(ServerStats::Processing); ServerStats::LogBytes(size); if (RuntimeOption::EnableStats && RuntimeOption::EnableWebStats) { ServerStats::Log("network.uncompressed", size); ServerStats::Log("network.compressed", response.size()); }}
开发者ID:oxromantic,项目名称:hiphop-php,代码行数:52,
示例10: TESTTEST(time, timer_create_NULL) { // A NULL sigevent* is equivalent to asking for SIGEV_SIGNAL for SIGALRM. timer_t timer_id; ASSERT_EQ(0, timer_create(CLOCK_MONOTONIC, NULL, &timer_id)); ScopedSignalHandler ssh(SIGALRM, timer_create_NULL_signal_handler); ASSERT_EQ(0, timer_create_NULL_signal_handler_invocation_count); SetTime(timer_id, 0, 1, 0, 0); usleep(500000); ASSERT_EQ(1, timer_create_NULL_signal_handler_invocation_count);}
开发者ID:WTree,项目名称:platform_bionic,代码行数:14,
示例11: okaybool ServerConfigurationDialog::testSshConnection(ServerConfiguration const& configuration){ bool okay(false); try { QString hostAddress(configuration.value(ServerConfiguration::HostAddress)); QString userName(configuration.value(ServerConfiguration::UserName)); Network::Connection::AuthenticationT authentication(configuration.authentication()); int port(configuration.port()); Network::SshConnection ssh(hostAddress, port); ssh.open(); ssh.authenticate(authentication, userName); QLOG_TRACE() << "Authentication successful"; QEventLoop loop; Network::Reply* reply(ssh.execute("ls")); QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); loop.exec(); okay = (reply->status() == Network::Reply::Finished); if (okay) { QLOG_DEBUG() << "----------------------------"; QLOG_DEBUG() << reply->message(); QLOG_DEBUG() << "----------------------------"; }else { QString msg("Connection failed:/n"); msg += reply->message(); QMsgBox::warning(this, "IQmol", msg); } delete reply; }catch (Network::AuthenticationCancelled& err) { // don't do anything }catch (Network::AuthenticationError& err) { QMsgBox::warning(0, "IQmol", "Invalid username or password"); }catch (Exception& err) { okay = false; QMsgBox::warning(0, "IQmol", err.what()); } return okay;}
开发者ID:jlane-waikato,项目名称:IQmol,代码行数:46,
示例12: sshvoid HxRotateSpatialGraphStackSliceAndCDP::rotateSlice(HxSpatialGraph* graph, const double angle) { mtalign::SliceSelector ssh(graph, "TransformInfo"); SpatialGraphSelection fullSliceSelection; ssh.getSlice(ssh.getSliceAttributeValueFromIndex(1), fullSliceSelection); McMat3f rotMat = McMat3f::IDENTITY; rotMat[0][0] = cos(angle); rotMat[0][1] = -sin(angle); rotMat[1][0] = sin(angle); rotMat[1][1] = cos(angle); // compute barycenter McVec3f barycenter(0, 0, 0); for (int i = 0; i < fullSliceSelection.getNumSelectedVertices(); i++) { barycenter += graph->getVertexCoords(fullSliceSelection.getSelectedVertex(i)); } barycenter /= fullSliceSelection.getNumSelectedVertices(); McVec3f rotatedBarycenter; rotMat.multMatrixVec(barycenter, rotatedBarycenter); McVec3f translation = barycenter - rotatedBarycenter; for (int i = 0; i < fullSliceSelection.getNumSelectedEdges(); i++) { int edge = fullSliceSelection.getSelectedEdge(i); McDArray<McVec3f> newEdgePoints; for (int j = 0; j < graph->getNumEdgePoints(edge); j++) { McVec3f edgePoint = graph->getEdgePoint(edge, j); McVec3f rotatedEdgePoint; rotMat.multMatrixVec(edgePoint, rotatedEdgePoint); rotatedEdgePoint += translation; newEdgePoints.append(rotatedEdgePoint); } graph->setEdgePoints(edge, newEdgePoints); } for (int i = 0; i < fullSliceSelection.getNumSelectedVertices(); i++) { int curVertex = fullSliceSelection.getSelectedVertex(i); McVec3f curCoord = graph->getVertexCoords(curVertex); McVec3f rotatedVertex; rotMat.multMatrixVec(curCoord, rotatedVertex); rotatedVertex += translation; graph->setVertexCoords(curVertex, rotatedVertex); }}
开发者ID:zibamira,项目名称:microtubulestitching,代码行数:43,
示例13: DoCloseSessionvoid SFTPTreeView::DoOpenSession(){ DoCloseSession(); wxString accountName = m_choiceAccount->GetStringSelection(); if(accountName.IsEmpty()) { return; } SFTPSettings settings; settings.Load(); m_account = SSHAccountInfo(); if(!settings.GetAccount(accountName, m_account)) { ::wxMessageBox(wxString() << _("Could not find account: ") << accountName, "codelite", wxICON_ERROR | wxOK); return; } clSSH::Ptr_t ssh( new clSSH(m_account.GetHost(), m_account.GetUsername(), m_account.GetPassword(), m_account.GetPort())); try { wxString message; m_plugin->GetManager()->SetStatusMessage(wxString() << _("Connecting to: ") << accountName << "..."); ssh->Connect(); if(!ssh->AuthenticateServer(message)) { if(::wxMessageBox(message, "SSH", wxYES_NO | wxCENTER | wxICON_QUESTION) == wxYES) { ssh->AcceptServerAuthentication(); } } ssh->Login(); m_sftp.reset(new clSFTP(ssh)); m_sftp->Initialize(); m_sftp->SetAccount(m_account.GetAccountName()); m_plugin->GetManager()->SetStatusMessage(wxString() << _("Done!")); DoBuildTree("/"); } catch(clException& e) { ::wxMessageBox(e.What(), "codelite", wxICON_ERROR | wxOK); DoCloseSession(); }}
开发者ID:LoviPanda,项目名称:codelite,代码行数:41,
示例14: timebool RPCRequestHandler::executePHPFunction(Transport *transport, SourceRootInfo &sourceRootInfo) { // reset timeout counter ThreadInfo::s_threadInfo->m_reqInjectionData.started = time(0); string rpcFunc = transport->getCommand(); { ServerStatsHelper ssh("input"); RequestURI reqURI(rpcFunc); HttpProtocol::PrepareSystemVariables(transport, reqURI, sourceRootInfo); } bool isFile = rpcFunc.rfind('.') != string::npos; string rpcFile; bool error = false; Array params; string sparams = transport->getParam("params"); if (!sparams.empty()) { Variant jparams = f_json_decode(String(sparams), true); if (jparams.isArray()) { params = jparams.toArray(); } else { error = true; } } else { vector<string> sparams; transport->getArrayParam("p", sparams); if (!sparams.empty()) { for (unsigned int i = 0; i < sparams.size(); i++) { Variant jparams = f_json_decode(String(sparams[i]), true); if (same(jparams, false)) { error = true; break; } params.append(jparams); } } else { // single string parameter, used by xbox to avoid any en/decoding int size; const void *data = transport->getPostData(size); if (data && size) { params.append(String((char*)data, size, AttachLiteral)); } } } if (transport->getIntParam("reset") == 1) { m_reset = true; } int output = transport->getIntParam("output"); int code; if (!error) { Variant funcRet; string errorMsg = "Internal Server Error"; string warmupDoc, reqInitFunc, reqInitDoc; if (m_serverInfo) { warmupDoc = m_serverInfo->getWarmupDoc(); reqInitFunc = m_serverInfo->getReqInitFunc(); reqInitDoc = m_serverInfo->getReqInitDoc(); } if (!warmupDoc.empty()) warmupDoc = canonicalize_path(warmupDoc, "", 0); if (!warmupDoc.empty()) { warmupDoc = getSourceFilename(warmupDoc, sourceRootInfo); } if (!reqInitDoc.empty()) reqInitDoc = canonicalize_path(reqInitDoc, "", 0); if (!reqInitDoc.empty()) { reqInitDoc = getSourceFilename(reqInitDoc, sourceRootInfo); } bool runOnce = false; bool ret = true; if (isFile) { rpcFile = rpcFunc; rpcFunc.clear(); } else { rpcFile = transport->getParam("include"); if (rpcFile.empty()) { rpcFile = transport->getParam("include_once"); runOnce = true; } } if (!rpcFile.empty()) { // invoking a file through rpc bool forbidden = false; if (!RuntimeOption::ForbiddenFileExtensions.empty()) { const char *ext = rpcFile.c_str() + rpcFile.rfind('.') + 1; if (RuntimeOption::ForbiddenFileExtensions.find(ext) != RuntimeOption::ForbiddenFileExtensions.end()) { forbidden = true; } } if (!forbidden) { rpcFile = canonicalize_path(rpcFile, "", 0); rpcFile = getSourceFilename(rpcFile, sourceRootInfo); ret = hphp_invoke(m_context, rpcFile, false, Array(), null, warmupDoc, reqInitFunc, reqInitDoc, error, errorMsg, runOnce);//.........这里部分代码省略.........
开发者ID:jhockly,项目名称:RED-COLOR-IS-MY-FAVORITE-COLOR,代码行数:101,
示例15: epvoid HttpRequestHandler::handleRequest(Transport *transport) { ExecutionProfiler ep(ThreadInfo::RuntimeFunctions); Logger::OnNewRequest(); GetAccessLog().onNewRequest(); transport->enableCompression(); ServerStatsHelper ssh("all", true); Logger::Verbose("receiving %s", transport->getCommand().c_str()); // will clear all extra logging when this function goes out of scope StackTraceNoHeap::ExtraLoggingClearer clearer; StackTraceNoHeap::AddExtraLogging("URL", transport->getUrl()); // resolve virtual host const VirtualHost *vhost = HttpProtocol::GetVirtualHost(transport); ASSERT(vhost); if (vhost->disabled() || vhost->isBlocking(transport->getCommand(), transport->getRemoteHost())) { transport->sendString("Not Found", 404); return; } ServerStats::StartRequest(transport->getCommand().c_str(), transport->getRemoteHost(), vhost->getName().c_str()); // resolve source root string host = transport->getHeader("Host"); SourceRootInfo sourceRootInfo(host.c_str()); if (sourceRootInfo.error()) { sourceRootInfo.handleError(transport); return; } // request URI string pathTranslation = m_pathTranslation ? vhost->getPathTranslation().c_str() : ""; RequestURI reqURI(vhost, transport, sourceRootInfo.path(), pathTranslation); if (reqURI.done()) { return; // already handled with redirection or 404 } string path = reqURI.path().data(); string absPath = reqURI.absolutePath().data(); // determine whether we should compress response bool compressed = transport->decideCompression(); const char *data; int len; size_t pos = path.rfind('.'); const char *ext = (pos != string::npos) && path.find('/', pos) == string::npos // no extention in ./foo or ../bar ? (path.c_str() + pos + 1) : NULL; bool cachableDynamicContent = (!RuntimeOption::StaticFileGenerators.empty() && RuntimeOption::StaticFileGenerators.find(path) != RuntimeOption::StaticFileGenerators.end()); // If this is not a php file, check the static and dynamic content caches if (ext && strcasecmp(ext, "php") != 0) { if (RuntimeOption::EnableStaticContentCache) { bool original = compressed; // check against static content cache if (StaticContentCache::TheCache.find(path, data, len, compressed)) { struct stat st; st.st_mtime = 0; String str; // (qigao) not calling stat at this point because the timestamp of // local cache file is not valuable, maybe misleading. This way // the Last-Modified header will not show in response. // stat(RuntimeOption::FileCache.c_str(), &st); if (!original && compressed) { data = gzdecode(data, len); if (data == NULL) { throw FatalErrorException("cannot unzip compressed data"); } compressed = false; str = NEW(StringData)(data, len, AttachString); } sendStaticContent(transport, data, len, st.st_mtime, compressed, path); StaticContentCache::TheFileCache->adviseOutMemory(); ServerStats::LogPage(path, 200); return; } } if (RuntimeOption::EnableStaticContentFromDisk) { String translated = File::TranslatePath(String(absPath)); if (!translated.empty()) { StringBuffer sb(translated.data()); if (sb.valid()) { struct stat st; st.st_mtime = 0; stat(translated.data(), &st); sendStaticContent(transport, sb.data(), sb.size(), st.st_mtime, false, path); ServerStats::LogPage(path, 200); return; }//.........这里部分代码省略.........
开发者ID:activeingredient,项目名称:hiphop-php,代码行数:101,
示例16: hphp_context_initbool HttpRequestHandler::executePHPRequest(Transport *transport, RequestURI &reqURI, SourceRootInfo &sourceRootInfo, bool cachableDynamicContent) { ExecutionContext *context = hphp_context_init(); context->setTransport(transport); string file = reqURI.absolutePath().c_str(); { ServerStatsHelper ssh("input"); HttpProtocol::PrepareSystemVariables(transport, reqURI, sourceRootInfo); reqURI.clear(); sourceRootInfo.clear(); } bool error = false; std::string errorMsg = "Internal Server Error"; bool ret = hphp_invoke(context, file, false, Array(), null, RuntimeOption::WarmupDocument, RuntimeOption::RequestInitFunction, error, errorMsg); int code; if (ret) { std::string content = context->getContents(); if (cachableDynamicContent && !content.empty()) { ASSERT(transport->getUrl()); string key = file + transport->getUrl(); DynamicContentCache::TheCache.store(key, content.data(), content.size()); } code = 200; transport->sendRaw((void*)content.data(), content.size()); } else if (error) { code = 500; string errorPage = context->getErrorPage(); if (errorPage.empty()) { errorPage = RuntimeOption::ErrorDocument500; } if (!errorPage.empty()) { context->obEndAll(); context->obStart(); context->obProtect(true); ret = hphp_invoke(context, errorPage, false, Array(), null, RuntimeOption::WarmupDocument, RuntimeOption::RequestInitFunction, error, errorMsg); if (ret) { std::string content = context->getContents(); transport->sendRaw((void*)content.data(), content.size()); } else { errorPage.clear(); // so we fall back to 500 return } } if (errorPage.empty()) { if (RuntimeOption::ServerErrorMessage) { transport->sendString(errorMsg, 500); } else { transport->sendString(RuntimeOption::FatalErrorMessage, 500); } } } else { code = 404; transport->sendString("Not Found", 404); } transport->onSendEnd(); ServerStats::LogPage(file, code); hphp_context_exit(context, true); return ret;}
开发者ID:sumitk,项目名称:hiphop-php,代码行数:70,
示例17: GetAccessLogvoid HttpRequestHandler::handleRequest(Transport *transport) { Logger::OnNewRequest(); GetAccessLog().onNewRequest(); transport->enableCompression(); Logger::Verbose("receiving %s", transport->getCommand().c_str()); ServerStatsHelper ssh("all", true); // resolve virtual host const VirtualHost *vhost = HttpProtocol::GetVirtualHost(transport); ASSERT(vhost); if (vhost->disabled() || vhost->isBlocking(transport->getCommand(), transport->getRemoteHost())) { transport->sendString("Not Found", 404); return; } ServerStats::StartRequest(transport->getCommand().c_str(), transport->getRemoteHost(), vhost->getName().c_str()); // resolve source root string host = transport->getHeader("Host"); SourceRootInfo sourceRootInfo(host.c_str()); if (sourceRootInfo.error()) { sourceRootInfo.handleError(transport); return; } // request URI string pathTranslation = m_pathTranslation ? vhost->getPathTranslation().c_str() : ""; RequestURI reqURI(vhost, transport, sourceRootInfo.path(), pathTranslation); if (reqURI.done()) { return; // already handled with redirection or 404 } string path = reqURI.path().data(); string absPath = reqURI.absolutePath().data(); bool compressed = transport->acceptEncoding("gzip"); const char *data; int len; size_t pos = path.rfind('.'); const char *ext = (pos != string::npos) ? (path.c_str() + pos + 1) : NULL; bool cachableDynamicContent = (!RuntimeOption::StaticFileGenerators.empty() && RuntimeOption::StaticFileGenerators.find(path) != RuntimeOption::StaticFileGenerators.end()); // If this is not a php file, check the static and dynamic content caches if (ext && strcasecmp(ext, "php") != 0) { if (RuntimeOption::EnableStaticContentCache) { // check against static content cache if (StaticContentCache::TheCache.find(path, data, len, compressed)) { struct stat st; st.st_mtime = 0; // (qigao) not calling stat at this point because the timestamp of // local cache file is not valuable, maybe misleading. This way // the Last-Modified header will not show in response. // stat(RuntimeOption::FileCache.c_str(), &st); sendStaticContent(transport, data, len, st.st_mtime, compressed, path); ServerStats::LogPage(path, 200); return; } } if (RuntimeOption::EnableStaticContentFromDisk && RuntimeOption::StaticFileExtensions.find(ext) != RuntimeOption::StaticFileExtensions.end()) { String translated = File::TranslatePath(String(absPath)); if (!translated.empty()) { StringBuffer sb(translated.data()); if (sb.valid()) { struct stat st; st.st_mtime = 0; stat(translated.data(), &st); sendStaticContent(transport, sb.data(), sb.size(), st.st_mtime, false, path); ServerStats::LogPage(path, 200); return; } } } // check static contents that were generated by dynamic pages if (cachableDynamicContent) { // check against dynamic content cache ASSERT(transport->getUrl()); string key = path + transport->getUrl(); if (DynamicContentCache::TheCache.find(key, data, len, compressed)) { sendStaticContent(transport, data, len, 0, compressed, path); ServerStats::LogPage(path, 200); return; } } } // proxy any URLs that not specified in ServeURLs if (!RuntimeOption::ProxyOrigin.empty() && ((RuntimeOption::UseServeURLs && RuntimeOption::ServeURLs.find(path) ==//.........这里部分代码省略.........
开发者ID:sumitk,项目名称:hiphop-php,代码行数:101,
示例18: DoCloseSessionvoid SFTPTreeView::DoOpenSession(){ DoCloseSession(); wxString accountName = m_choiceAccount->GetStringSelection(); if(accountName.IsEmpty()) { return; } SFTPSettings settings; settings.Load(); m_account = SSHAccountInfo(); if(!settings.GetAccount(accountName, m_account)) { ::wxMessageBox(wxString() << _("Could not find account: ") << accountName, "codelite", wxICON_ERROR | wxOK); return; } wxString message;#ifndef _WIN64 wxProgressDialog dlg(_("SFTP"), wxString(' ', 100) + "/n/n", 10); dlg.Show(); dlg.Update(1, wxString() << _("Connecting to: ") << accountName << "..." << _("/n(this may take a few seconds)"));#else wxBusyCursor bc; clGetManager()->SetStatusMessage(wxString() << _("Connecting to: ") << accountName);#endif // We know that there is a bug that libssh succeeded on connecting only on the second attempt.. // to workaround it, we issue first connect with 1 second timeout, and then re-open the connection try { clSSH::Ptr_t ssh( new clSSH(m_account.GetHost(), m_account.GetUsername(), m_account.GetPassword(), m_account.GetPort())); ssh->Connect(wxNOT_FOUND); } catch(...) { } try { clSSH::Ptr_t ssh( new clSSH(m_account.GetHost(), m_account.GetUsername(), m_account.GetPassword(), m_account.GetPort())); ssh->Connect(5);#ifndef _WIN64 dlg.Update(5, _("Connected!")); dlg.Update(6, _("Authenticating server..."));#endif if(!ssh->AuthenticateServer(message)) { if(::wxMessageBox(message, "SSH", wxYES_NO | wxCENTER | wxICON_QUESTION) == wxYES) {#ifndef _WIN64 dlg.Update(7, _("Accepting server authentication server..."));#endif ssh->AcceptServerAuthentication(); } } else {#ifndef _WIN64 dlg.Update(7, _("Server authenticated"));#endif }#ifndef _WIN64 dlg.Update(8, _("Logging..."));#endif ssh->Login(); m_sftp.reset(new clSFTP(ssh)); m_sftp->Initialize(); m_sftp->SetAccount(m_account.GetAccountName()); m_plugin->GetManager()->SetStatusMessage(wxString() << _("Done!"));#ifndef _WIN64 dlg.Update(9, _("Fetching directory list..."));#endif DoBuildTree(m_account.GetDefaultFolder().IsEmpty() ? "/" : m_account.GetDefaultFolder());#ifndef _WIN64 dlg.Update(10, _("Done"));#endif } catch(clException& e) { ::wxMessageBox(e.What(), "codelite", wxICON_ERROR | wxOK); DoCloseSession(); }}
开发者ID:Jactry,项目名称:codelite,代码行数:80,
示例19: timebool RPCRequestHandler::executePHPFunction(Transport *transport, SourceRootInfo &sourceRootInfo) { // reset timeout counter ThreadInfo::s_threadInfo->m_reqInjectionData.started = time(0); std::string rpcFunc = transport->getCommand(); { ServerStatsHelper ssh("input"); RequestURI reqURI(rpcFunc); HttpProtocol::PrepareSystemVariables(transport, reqURI, sourceRootInfo); sourceRootInfo.clear(); } bool error = false; Array params; std::string sparams = transport->getParam("params"); if (!sparams.empty()) { Variant jparams = f_json_decode(String(sparams), true); if (jparams.isArray()) { params = jparams.toArray(); } else { error = true; } } else { vector<string> sparams; transport->getArrayParam("p", sparams); if (!sparams.empty()) { for (unsigned int i = 0; i < sparams.size(); i++) { Variant jparams = f_json_decode(String(sparams[i]), true); if (same(jparams, false)) { error = true; break; } params.append(jparams); } } else { // single string parameter, used by xbox to avoid any en/decoding int size; const void *data = transport->getPostData(size); if (data && size) { params.append(String((char*)data, size, AttachLiteral)); } } } if (transport->getIntParam("reset") == 1) { m_reset = true; } int output = transport->getIntParam("output"); int code; if (!error) { Variant funcRet; std::string errorMsg = "Internal Server Error"; string warmupDoc, reqInitFunc, reqInitDoc; if (m_serverInfo) { warmupDoc = m_serverInfo->getWarmupDoc(); reqInitFunc = m_serverInfo->getReqInitFunc(); reqInitDoc = m_serverInfo->getReqInitDoc(); } if (!warmupDoc.empty()) warmupDoc = canonicalize_path(warmupDoc, "", 0); if (!warmupDoc.empty()) warmupDoc = get_source_filename(warmupDoc.c_str()); bool ret = hphp_invoke(m_context, rpcFunc, true, params, ref(funcRet), warmupDoc, reqInitFunc, reqInitDoc, error, errorMsg); if (ret) { String response; switch (output) { case 0: response = f_json_encode(funcRet); break; case 1: response = m_context->obDetachContents(); break; case 2: response = f_json_encode(CREATE_MAP2("output", m_context->obDetachContents(), "return", f_json_encode(funcRet))); break; } code = 200; transport->sendRaw((void*)response.data(), response.size()); } else if (error) { code = 500; transport->sendString(errorMsg, 500); m_reset = true; } else { code = 404; transport->sendString("Not Found", 404); } } else { code = 400; transport->sendString("Bad Request", 400); } params.reset(); transport->onSendEnd(); ServerStats::LogPage(rpcFunc, code); m_context->onShutdownPostSend(); m_context->restoreSession(); return !error;}
开发者ID:diegoIta,项目名称:hiphop-php,代码行数:100,
示例20: epvoid RPCRequestHandler::handleRequest(Transport *transport) { ExecutionProfiler ep(ThreadInfo::RuntimeFunctions); Logger::OnNewRequest(); HttpRequestHandler::GetAccessLog().onNewRequest(); m_context->setTransport(transport); transport->enableCompression(); ServerStatsHelper ssh("all", ServerStatsHelper::TRACK_MEMORY); Logger::Verbose("receiving %s", transport->getCommand().c_str()); // will clear all extra logging when this function goes out of scope StackTraceNoHeap::ExtraLoggingClearer clearer; StackTraceNoHeap::AddExtraLogging("RPC-URL", transport->getUrl()); // authentication const set<string> &passwords = m_serverInfo->getPasswords(); if (!passwords.empty()) { set<string>::const_iterator iter = passwords.find(transport->getParam("auth")); if (iter == passwords.end()) { transport->sendString("Unauthorized", 401); transport->onSendEnd(); HttpRequestHandler::GetAccessLog().log(transport, nullptr); /* * HPHP logs may need to access data in ServerStats, so we have to * clear the hashtable after writing the log entry. */ ServerStats::Reset(); return; } } else { const string &password = m_serverInfo->getPassword(); if (!password.empty() && password != transport->getParam("auth")) { transport->sendString("Unauthorized", 401); transport->onSendEnd(); HttpRequestHandler::GetAccessLog().log(transport, nullptr); /* * HPHP logs may need to access data in ServerStats, so we have to * clear the hashtable after writing the log entry. */ ServerStats::Reset(); return; } } // return encoding type if (transport->getParam("return") == "serialize") { setReturnEncodeType(Serialize); } // resolve virtual host const VirtualHost *vhost = HttpProtocol::GetVirtualHost(transport); assert(vhost); if (vhost->disabled()) { transport->sendString("Virtual host disabled.", 404); transport->onSendEnd(); HttpRequestHandler::GetAccessLog().log(transport, vhost); return; } vhost->setRequestTimeoutSeconds(); // resolve source root string host = transport->getHeader("Host"); SourceRootInfo sourceRootInfo(host.c_str()); // set thread type switch (m_serverInfo->getType()) { case SatelliteServer::KindOfRPCServer: transport->setThreadType(Transport::RpcThread); break; case SatelliteServer::KindOfXboxServer: transport->setThreadType(Transport::XboxThread); break; default: break; } // record request for debugging purpose std::string tmpfile = HttpProtocol::RecordRequest(transport); bool ret = executePHPFunction(transport, sourceRootInfo); HttpRequestHandler::GetAccessLog().log(transport, vhost); /* * HPHP logs may need to access data in ServerStats, so we have to * clear the hashtable after writing the log entry. */ ServerStats::Reset(); HttpProtocol::ClearRecord(ret, tmpfile);}
开发者ID:CyaLiven,项目名称:hiphop-php,代码行数:89,
示例21: hphp_context_initbool HttpRequestHandler::executePHPRequest(Transport *transport, RequestURI &reqURI, SourceRootInfo &sourceRootInfo, bool cachableDynamicContent) { ExecutionContext *context = hphp_context_init(); if (RuntimeOption::ImplicitFlush) { context->obSetImplicitFlush(true); } if (RuntimeOption::EnableOutputBuffering) { if (RuntimeOption::OutputHandler.empty()) { context->obStart(); } else { context->obStart(String(RuntimeOption::OutputHandler)); } } context->setTransport(transport); string file = reqURI.absolutePath().c_str(); { ServerStatsHelper ssh("input"); HttpProtocol::PrepareSystemVariables(transport, reqURI, sourceRootInfo); if (RuntimeOption::EnableDebugger) { Eval::DSandboxInfo sInfo = sourceRootInfo.getSandboxInfo(); Eval::Debugger::RegisterSandbox(sInfo); context->setSandboxId(sInfo.id()); } reqURI.clear(); sourceRootInfo.clear(); } int code; bool ret = true; if (RuntimeOption::EnableDebugger) { Eval::Debugger::InterruptRequestStarted(transport->getUrl()); } bool error = false; std::string errorMsg = "Internal Server Error"; ret = hphp_invoke(context, file, false, Array(), uninit_null(), RuntimeOption::RequestInitFunction, RuntimeOption::RequestInitDocument, error, errorMsg); if (ret) { String content = context->obDetachContents(); if (cachableDynamicContent && !content.empty()) { assert(transport->getUrl()); string key = file + transport->getUrl(); DynamicContentCache::TheCache.store(key, content.data(), content.size()); } transport->sendRaw((void*)content.data(), content.size()); code = transport->getResponseCode(); } else if (error) { code = 500; string errorPage = context->getErrorPage().data(); if (errorPage.empty()) { errorPage = RuntimeOption::ErrorDocument500; } if (!errorPage.empty()) { context->obProtect(false); context->obEndAll(); context->obStart(); context->obProtect(true); ret = hphp_invoke(context, errorPage, false, Array(), uninit_null(), RuntimeOption::RequestInitFunction, RuntimeOption::RequestInitDocument, error, errorMsg); if (ret) { String content = context->obDetachContents(); transport->sendRaw((void*)content.data(), content.size()); code = transport->getResponseCode(); } else { Logger::Error("Unable to invoke error page %s", errorPage.c_str()); errorPage.clear(); // so we fall back to 500 return } } if (errorPage.empty()) { if (RuntimeOption::ServerErrorMessage) { transport->sendString(errorMsg, 500, false, false, "hphp_invoke"); } else { transport->sendString(RuntimeOption::FatalErrorMessage, 500, false, false, "hphp_invoke"); } } } else { code = 404; transport->sendString("Not Found", 404); } if (RuntimeOption::EnableDebugger) { Eval::Debugger::InterruptRequestEnded(transport->getUrl()); } transport->onSendEnd(); hphp_context_exit(context, true, true, transport->getUrl()); ServerStats::LogPage(file, code);//.........这里部分代码省略.........
开发者ID:HendrikGrunstra,项目名称:hiphop-php,代码行数:101,
示例22: epvoid HttpRequestHandler::handleRequest(Transport *transport) { ExecutionProfiler ep(ThreadInfo::RuntimeFunctions); Logger::OnNewRequest(); GetAccessLog().onNewRequest(); transport->enableCompression(); ServerStatsHelper ssh("all", ServerStatsHelper::TRACK_MEMORY); Logger::Verbose("receiving %s", transport->getCommand().c_str()); // will clear all extra logging when this function goes out of scope StackTraceNoHeap::ExtraLoggingClearer clearer; StackTraceNoHeap::AddExtraLogging("URL", transport->getUrl()); // resolve virtual host const VirtualHost *vhost = HttpProtocol::GetVirtualHost(transport); assert(vhost); if (vhost->disabled() || vhost->isBlocking(transport->getCommand(), transport->getRemoteHost())) { transport->sendString("Not Found", 404); return; } // don't serve the request if it's been sitting in queue for longer than our // allowed request timeout. int requestTimeoutSeconds = vhost->getRequestTimeoutSeconds(getDefaultTimeout()); if (requestTimeoutSeconds > 0) { timespec now; Timer::GetMonotonicTime(now); const timespec& queueTime = transport->getQueueTime(); if (gettime_diff_us(queueTime, now) > requestTimeoutSeconds * 1000000) { transport->sendString("Service Unavailable", 503); m_requestTimedOutOnQueue->addValue(1); return; } } ServerStats::StartRequest(transport->getCommand().c_str(), transport->getRemoteHost(), vhost->getName().c_str()); // resolve source root string host = transport->getHeader("Host"); SourceRootInfo sourceRootInfo(host.c_str()); if (sourceRootInfo.error()) { sourceRootInfo.handleError(transport); return; } // request URI string pathTranslation = m_pathTranslation ? vhost->getPathTranslation().c_str() : ""; RequestURI reqURI(vhost, transport, sourceRootInfo.path(), pathTranslation); if (reqURI.done()) { return; // already handled with redirection or 404 } string path = reqURI.path().data(); string absPath = reqURI.absolutePath().data(); // determine whether we should compress response bool compressed = transport->decideCompression(); const char *data; int len; const char *ext = reqURI.ext(); if (reqURI.forbidden()) { transport->sendString("Forbidden", 403); return; } bool cachableDynamicContent = (!RuntimeOption::StaticFileGenerators.empty() && RuntimeOption::StaticFileGenerators.find(path) != RuntimeOption::StaticFileGenerators.end()); // If this is not a php file, check the static and dynamic content caches if (ext && strcasecmp(ext, "php") != 0) { if (RuntimeOption::EnableStaticContentCache) { bool original = compressed; // check against static content cache if (StaticContentCache::TheCache.find(path, data, len, compressed)) { Util::ScopedMem decompressed_data; // (qigao) not calling stat at this point because the timestamp of // local cache file is not valuable, maybe misleading. This way // the Last-Modified header will not show in response. // stat(RuntimeOption::FileCache.c_str(), &st); if (!original && compressed) { data = gzdecode(data, len); if (data == nullptr) { throw FatalErrorException("cannot unzip compressed data"); } decompressed_data = const_cast<char*>(data); compressed = false; } sendStaticContent(transport, data, len, 0, compressed, path, ext); StaticContentCache::TheFileCache->adviseOutMemory(); ServerStats::LogPage(path, 200);//.........这里部分代码省略.........
开发者ID:HendrikGrunstra,项目名称:hiphop-php,代码行数:101,
示例23: sshbool RPCRequestHandler::executePHPFunction(Transport *transport, SourceRootInfo &sourceRootInfo, ReturnEncodeType returnEncodeType) { string rpcFunc = transport->getCommand(); { ServerStatsHelper ssh("input"); RequestURI reqURI(rpcFunc); HttpProtocol::PrepareSystemVariables(transport, reqURI, sourceRootInfo); GlobalVariables *g = get_global_variables(); g->getRef(s__ENV).set(s_HPHP_RPC, 1); } bool isFile = rpcFunc.rfind('.') != string::npos; string rpcFile; bool error = false; Array params; string sparams = transport->getParam("params"); if (!sparams.empty()) { Variant jparams = f_json_decode(String(sparams), true); if (jparams.isArray()) { params = jparams.toArray(); } else { error = true; } } else { vector<string> sparams; transport->getArrayParam("p", sparams); if (!sparams.empty()) { for (unsigned int i = 0; i < sparams.size(); i++) { Variant jparams = f_json_decode(String(sparams[i]), true); if (same(jparams, false)) { error = true; break; } params.append(jparams); } } else { // single string parameter, used by xbox to avoid any en/decoding int size; const void *data = transport->getPostData(size); if (data && size) { params.append(String((char*)data, size, CopyString)); } } } if (transport->getIntParam("reset") == 1) { m_reset = true; } int output = transport->getIntParam("output"); int code; if (!error) { Variant funcRet; string errorMsg = "Internal Server Error"; string reqInitFunc, reqInitDoc; reqInitDoc = transport->getHeader("ReqInitDoc"); if (reqInitDoc.empty() && m_serverInfo) { reqInitFunc = m_serverInfo->getReqInitFunc(); reqInitDoc = m_serverInfo->getReqInitDoc(); } if (!reqInitDoc.empty()) { reqInitDoc = (std::string)canonicalize_path(reqInitDoc, "", 0); } if (!reqInitDoc.empty()) { reqInitDoc = getSourceFilename(reqInitDoc, sourceRootInfo); } bool runOnce = false; bool ret = true; if (isFile) { rpcFile = rpcFunc; rpcFunc.clear(); } else { rpcFile = transport->getParam("include"); if (rpcFile.empty()) { rpcFile = transport->getParam("include_once"); runOnce = true; } } if (!rpcFile.empty()) { // invoking a file through rpc bool forbidden = false; if (!RuntimeOption::ForbiddenFileExtensions.empty()) { const char *ext = rpcFile.c_str() + rpcFile.rfind('.') + 1; if (RuntimeOption::ForbiddenFileExtensions.find(ext) != RuntimeOption::ForbiddenFileExtensions.end()) { forbidden = true; } } if (!forbidden) { rpcFile = (std::string) canonicalize_path(rpcFile, "", 0); rpcFile = getSourceFilename(rpcFile, sourceRootInfo); ret = hphp_invoke(m_context, rpcFile, false, Array(), uninit_null(), reqInitFunc, reqInitDoc, error, errorMsg, runOnce); } // no need to do the initialization for a second time//.........这里部分代码省略.........
开发者ID:Halfnhav,项目名称:hiphop-php,代码行数:101,
示例24: TESTTEST(pthread, pthread_kill__in_signal_handler) { ScopedSignalHandler ssh(SIGALRM, pthread_kill__in_signal_handler_helper); ASSERT_EQ(0, pthread_kill(pthread_self(), SIGALRM));}
开发者ID:nick0lay,项目名称:platform_bionic,代码行数:4,
示例25: selfJSObject *GlobalObject::initFunctionAndObjectClasses(JSContext *cx){ Rooted<GlobalObject*> self(cx, this); JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment); JS_ASSERT(isNative()); /* * Calling a function from a cleared global triggers this (yeah, I know). * Uncomment this once bug 470510 is fixed (if that bug doesn't remove * isCleared entirely). */ // JS_ASSERT(!isCleared()); /* If cx has no global object, make this the global object. */ if (!cx->globalObject) JS_SetGlobalObject(cx, self); RootedObject objectProto(cx); /* * Create |Object.prototype| first, mirroring CreateBlankProto but for the * prototype of the created object. */ objectProto = NewObjectWithGivenProto(cx, &ObjectClass, NULL, self); if (!objectProto || !objectProto->setSingletonType(cx)) return NULL; /* * The default 'new' type of Object.prototype is required by type inference * to have unknown properties, to simplify handling of e.g. heterogenous * objects in JSON and script literals. */ if (!objectProto->setNewTypeUnknown(cx)) return NULL; /* Create |Function.prototype| next so we can create other functions. */ RootedFunction functionProto(cx); { JSObject *functionProto_ = NewObjectWithGivenProto(cx, &FunctionClass, objectProto, self); if (!functionProto_) return NULL; functionProto = functionProto_->toFunction(); /* * Bizarrely, |Function.prototype| must be an interpreted function, so * give it the guts to be one. */ JSObject *proto = js_NewFunction(cx, functionProto, NULL, 0, JSFUN_INTERPRETED, self, NULL); if (!proto) return NULL; JS_ASSERT(proto == functionProto); functionProto->flags |= JSFUN_PROTOTYPE; const char *rawSource = "() {/n}"; size_t sourceLen = strlen(rawSource); jschar *source = InflateString(cx, rawSource, &sourceLen); if (!source) return NULL; ScriptSource *ss = cx->new_<ScriptSource>(); if (!ss) { cx->free_(source); return NULL; } ScriptSourceHolder ssh(cx->runtime, ss); ss->setSource(source, sourceLen); CompileOptions options(cx); options.setNoScriptRval(true) .setVersion(JSVERSION_DEFAULT); Rooted<JSScript*> script(cx, JSScript::Create(cx, /* enclosingScope = */ NullPtr(), /* savedCallerFun = */ false, options, /* staticLevel = */ 0, ss, 0, ss->length())); if (!script || !JSScript::fullyInitTrivial(cx, script)) return NULL; functionProto->initScript(script); functionProto->getType(cx)->interpretedFunction = functionProto; script->setFunction(functionProto); if (!functionProto->setSingletonType(cx)) return NULL; /* * The default 'new' type of Function.prototype is required by type * inference to have unknown properties, to simplify handling of e.g. * CloneFunctionObject. */ if (!functionProto->setNewTypeUnknown(cx)) return NULL; } /* Create the Object function now that we have a [[Prototype]] for it. *///.........这里部分代码省略.........
开发者ID:sjnewbury,项目名称:fennec-qt-maemo5,代码行数:101,
注:本文中的ssh函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ ssh_buffer_free函数代码示例 C++ ssd1306_command函数代码示例 |