void MonitorStartServer(const Policy *policy, const ReportContext *report_context) { char timekey[CF_SMALLBUF]; Averages averages; Promise *pp = NewPromise("monitor_cfengine", "the monitor daemon"); Attributes dummyattr; CfLock thislock; #ifdef __MINGW32__ if (!NO_FORK) { CfOut(cf_verbose, "", "Windows does not support starting processes in the background - starting in foreground"); } #else /* !__MINGW32__ */ if ((!NO_FORK) && (fork() != 0)) { CfOut(cf_inform, "", "cf-monitord: starting\n"); _exit(0); } if (!NO_FORK) { ActAsDaemon(0); } #endif /* !__MINGW32__ */ memset(&dummyattr, 0, sizeof(dummyattr)); dummyattr.transaction.ifelapsed = 0; dummyattr.transaction.expireafter = 0; thislock = AcquireLock(pp->promiser, VUQNAME, CFSTARTTIME, dummyattr, pp, false); if (thislock.lock == NULL) { return; } WritePID("cf-monitord.pid"); MonNetworkSnifferOpen(); while (!IsPendingTermination()) { GetQ(policy, report_context); snprintf(timekey, sizeof(timekey), "%s", GenTimeKey(time(NULL))); averages = EvalAvQ(timekey); LeapDetection(); ArmClasses(averages, timekey); ZeroArrivals(); MonNetworkSnifferSniff(ITER, CF_THIS); ITER++; } }
ClusterGraph::ClusterGraph(const ClusterStructure& clusterStructure, const std::vector<AutomataStatesPair>& stablePairs): adjacencyList(0, 0), clusterStructure(clusterStructure), stablePairs(stablePairs) { adjacencyList = MultiListGraph<ClusterGraphEdge>(clusterStructure.GetClusterCount(), 2*stablePairs.size()); for (size_t i = 0; i < stablePairs.size(); ++i) { auto stablePair = stablePairs[i]; int pCluster = clusterStructure.GetVertexInfos()[stablePair.GetP()].clusterIndex; int qCluster = clusterStructure.GetVertexInfos()[stablePair.GetQ()].clusterIndex; if (!clusterStructure.IsBigCluster(pCluster) || !clusterStructure.IsBigCluster(qCluster)) continue; adjacencyList.AddEdge(pCluster, ClusterGraphEdge(qCluster, stablePair.GetP(), stablePair.GetQ())); adjacencyList.AddEdge(qCluster, ClusterGraphEdge(pCluster, stablePair.GetQ(), stablePair.GetP())); } size_t n = clusterStructure.GetSingleLetterGraph().size(); levels = std::vector<int>(n, -1); for (size_t i = 0; i < n; ++i) { levels[i] = GetLevel(i, clusterStructure, levels); } }
void FbxParser::ApplyLocalTransform(GameObjectPtr node, FbxNode* fbxNode) { auto matrix = fbxNode->EvaluateLocalTransform(); auto fbxQ = matrix.GetQ(); auto fbxT = matrix.GetT(); auto fbxS = matrix.GetS(); Vector3 trans{ fbxT.mData }; Vector3 scale{ fbxS.mData }; Quaternion rotation{ (float)fbxQ.mData[0], (float)fbxQ.mData[1], (float)fbxQ.mData[2], (float)fbxQ.mData[3]}; node->SetLocalPosition(trans); node->SetLocalRotate(rotation); node->SetLocalScale(scale); }
void MonitorStartServer(EvalContext *ctx, const Policy *policy) { char timekey[CF_SMALLBUF]; Averages averages; Policy *monitor_cfengine_policy = PolicyNew(); Promise *pp = NULL; { Bundle *bp = PolicyAppendBundle(monitor_cfengine_policy, NamespaceDefault(), "monitor_cfengine_bundle", "agent", NULL, NULL); PromiseType *tp = BundleAppendPromiseType(bp, "monitor_cfengine"); pp = PromiseTypeAppendPromise(tp, "the monitor daemon", (Rval) { NULL, RVAL_TYPE_NOPROMISEE }, NULL); } assert(pp); CfLock thislock; #ifdef __MINGW32__ if (!NO_FORK) { Log(LOG_LEVEL_VERBOSE, "Windows does not support starting processes in the background - starting in foreground"); } #else /* !__MINGW32__ */ if ((!NO_FORK) && (fork() != 0)) { Log(LOG_LEVEL_INFO, "cf-monitord: starting"); _exit(0); } if (!NO_FORK) { ActAsDaemon(0); } #endif /* !__MINGW32__ */ TransactionContext tc = { .ifelapsed = 0, .expireafter = 0, }; thislock = AcquireLock(ctx, pp->promiser, VUQNAME, CFSTARTTIME, tc, pp, false); if (thislock.lock == NULL) { PolicyDestroy(monitor_cfengine_policy); return; } WritePID("cf-monitord.pid"); MonNetworkSnifferOpen(); while (!IsPendingTermination()) { GetQ(ctx, policy); snprintf(timekey, sizeof(timekey), "%s", GenTimeKey(time(NULL))); averages = EvalAvQ(ctx, timekey); LeapDetection(); ArmClasses(averages, timekey); ZeroArrivals(); MonNetworkSnifferSniff(ITER, CF_THIS); ITER++; } PolicyDestroy(monitor_cfengine_policy); } /*********************************************************************/ static void GetQ(EvalContext *ctx, const Policy *policy) { MonEntropyClassesReset(); ZeroArrivals(); MonProcessesGatherData(CF_THIS); #ifndef __MINGW32__ MonCPUGatherData(CF_THIS); MonLoadGatherData(CF_THIS); MonDiskGatherData(CF_THIS); MonNetworkGatherData(CF_THIS); MonNetworkSnifferGatherData(); MonTempGatherData(CF_THIS); #endif /* !__MINGW32__ */ MonOtherGatherData(CF_THIS); GatherPromisedMeasures(ctx, policy); }
void CppDiffieHellman::Init() { _p_int = CryptoPP::Integer(reinterpret_cast<byte *>(GetP().data()), GetP().count()); _q_int = CryptoPP::Integer(reinterpret_cast<byte *>(GetQ().data()), GetQ().count()); _g_int = CryptoPP::Integer(reinterpret_cast<byte *>(GetG().data()), GetG().count()); }