void DSMFactory::runMonitorAppSelect(const AmSipRequest& req, string& start_diag, map<string, string>& vars) { #define FALLBACK_OR_EXCEPTION(code, reason) \ if (MonSelectFallback.empty()) { \ throw AmSession::Exception(code, reason); \ } else { \ DBG("falling back to '%s'\n", MonSelectFallback.c_str()); \ start_diag = MonSelectFallback; \ return; \ } #ifdef USE_MONITORING if (NULL == MONITORING_GLOBAL_INTERFACE) { ERROR("using $(mon_select) but monitoring not loaded\n"); FALLBACK_OR_EXCEPTION(500, "Internal Server Error"); } AmArg di_args, ret; if (MonSelectCaller != MonSelect_NONE) { AmUriParser from_parser; if (MonSelectCaller == MonSelect_FROM) from_parser.uri = req.from_uri; else { size_t end; string pai = getHeader(req.hdrs, SIP_HDR_P_ASSERTED_IDENTITY, true); if (!from_parser.parse_contact(pai, 0, end)) { WARN("Failed to parse " SIP_HDR_P_ASSERTED_IDENTITY " '%s'\n", pai.c_str()); FALLBACK_OR_EXCEPTION(500, "Internal Server Error"); } } if (!from_parser.parse_uri()) { DBG("failed to parse caller uri '%s'\n", from_parser.uri.c_str()); FALLBACK_OR_EXCEPTION(500, "Internal Server Error"); } AmArg caller_filter; caller_filter.push("caller"); caller_filter.push(from_parser.uri_user); DBG(" && looking for caller=='%s'\n", from_parser.uri_user.c_str()); di_args.push(caller_filter); } if (MonSelectCallee != MonSelect_NONE) { AmArg callee_filter; callee_filter.push("callee"); if (MonSelectCallee == MonSelect_RURI) callee_filter.push(req.user); else { AmUriParser to_parser; size_t end; if (!to_parser.parse_contact(req.to, 0, end)) { ERROR("Failed to parse To '%s'\n", req.to.c_str()); FALLBACK_OR_EXCEPTION(500, "Internal Server Error"); } if (!to_parser.parse_uri()) { DBG("failed to parse callee uri '%s'\n", to_parser.uri.c_str()); FALLBACK_OR_EXCEPTION(500, "Internal Server Error"); } callee_filter.push(to_parser.uri_user); } DBG(" && looking for callee=='%s'\n", req.user.c_str()); di_args.push(callee_filter); } // apply additional filters if (MonSelectFilters.size()) { string app_params = getHeader(req.hdrs, PARAM_HDR); for (vector<string>::iterator it = MonSelectFilters.begin(); it != MonSelectFilters.end(); it++) { AmArg filter; filter.push(*it); // avp name string app_param_val = get_header_keyvalue(app_params, *it); filter.push(app_param_val); di_args.push(filter); DBG(" && looking for %s=='%s'\n", it->c_str(), app_param_val.c_str()); } } MONITORING_GLOBAL_INTERFACE->invoke("listByFilter",di_args,ret); if ((ret.getType()!=AmArg::Array)|| !ret.size()) { DBG("call info not found. caller uri %s, r-uri %s\n", req.from_uri.c_str(), req.r_uri.c_str()); FALLBACK_OR_EXCEPTION(500, "Internal Server Error"); } AmArg sess_id, sess_params; if (ret.size()>1) { DBG("multiple call info found - picking the first one\n"); } const char* session_id = ret.get(0).asCStr(); sess_id.push(session_id); MONITORING_GLOBAL_INTERFACE->invoke("get",sess_id,sess_params); if ((sess_params.getType()!=AmArg::Array)|| !sess_params.size() || sess_params.get(0).getType() != AmArg::Struct) { INFO("call parameters not found. caller uri %s, r-uri %s, id %s\n", req.from_uri.c_str(), req.r_uri.c_str(), ret.get(0).asCStr()); FALLBACK_OR_EXCEPTION(500, "Internal Server Error"); } AmArg& sess_dict = sess_params.get(0); if (sess_dict.hasMember("app")) { start_diag = sess_dict["app"].asCStr(); DBG("selected application '%s' for session\n", start_diag.c_str()); } else { ERROR("selected session params don't contain 'app'\n"); FALLBACK_OR_EXCEPTION(500, "Internal Server Error"); } AmArg2DSMStrMap(sess_dict["appParams"], vars); vars["mon_session_record"] = session_id; #else ERROR("using $(mon_select) for dsm application, " "but compiled without monitoring support!\n"); throw AmSession::Exception(500, "Internal Server Error"); #endif #undef FALLBACK_OR_EXCEPTION }
int main (int argc, char *argv[]) { if(argc < 2) { ERR("usage: \n" << argv[0] << " <file.osm/.osm.bz2/.osm.pbf> [<profile.lua>]"); } INFO("extracting data from input file " << argv[1]); bool isPBF(false); std::string outputFileName(argv[1]); std::string restrictionsFileName(argv[1]); std::string::size_type pos = outputFileName.find(".osm.bz2"); if(pos==std::string::npos) { pos = outputFileName.find(".osm.pbf"); if(pos!=std::string::npos) { isPBF = true; } } if(pos!=string::npos) { outputFileName.replace(pos, 8, ".osrm"); restrictionsFileName.replace(pos, 8, ".osrm.restrictions"); } else { pos=outputFileName.find(".osm"); if(pos!=string::npos) { outputFileName.replace(pos, 5, ".osrm"); restrictionsFileName.replace(pos, 5, ".osrm.restrictions"); } else { outputFileName.append(".osrm"); restrictionsFileName.append(".osrm.restrictions"); } } /*** Setup Scripting Environment ***/ // Create a new lua state lua_State *myLuaState = luaL_newstate(); // Connect LuaBind to this lua state luabind::open(myLuaState); // Add our function to the state's global scope luabind::module(myLuaState) [ luabind::def("print", LUA_print<std::string>), luabind::def("parseMaxspeed", parseMaxspeed), luabind::def("durationIsValid", durationIsValid), luabind::def("parseDuration", parseDuration) ]; if(0 != luaL_dostring( myLuaState, "print('Initializing LUA engine')\n" )) { ERR(lua_tostring(myLuaState,-1)<< " occured in scripting block"); } luabind::module(myLuaState) [ luabind::class_<HashTable<std::string, std::string> >("keyVals") .def("Add", &HashTable<std::string, std::string>::Add) .def("Find", &HashTable<std::string, std::string>::Find) ]; luabind::module(myLuaState) [ luabind::class_<ImportNode>("Node") .def(luabind::constructor<>()) .def_readwrite("lat", &ImportNode::lat) .def_readwrite("lon", &ImportNode::lon) .def_readwrite("id", &ImportNode::id) .def_readwrite("bollard", &ImportNode::bollard) .def_readwrite("traffic_light", &ImportNode::trafficLight) .def_readwrite("tags", &ImportNode::keyVals) ]; luabind::module(myLuaState) [ luabind::class_<_Way>("Way") .def(luabind::constructor<>()) .def_readwrite("name", &_Way::name) .def_readwrite("speed", &_Way::speed) .def_readwrite("type", &_Way::type) .def_readwrite("access", &_Way::access) .def_readwrite("roundabout", &_Way::roundabout) .def_readwrite("is_duration_set", &_Way::isDurationSet) .def_readwrite("is_access_restricted", &_Way::isAccessRestricted) .def_readwrite("ignore_in_grid", &_Way::ignoreInGrid) .def_readwrite("tags", &_Way::keyVals) .def_readwrite("direction", &_Way::direction) .enum_("constants") [ luabind::value("notSure", 0), luabind::value("oneway", 1), luabind::value("bidirectional", 2), luabind::value("opposite", 3) ] ]; // Now call our function in a lua script INFO("Parsing speedprofile from " << (argc > 2 ? argv[2] : "profile.lua") ); if(0 != luaL_dofile(myLuaState, (argc > 2 ? argv[2] : "profile.lua") )) { ERR(lua_tostring(myLuaState,-1)<< " occured in scripting block"); } //open utility libraries string library; luaL_openlibs(myLuaState); /*** End of Scripting Environment Setup; ***/ unsigned amountOfRAM = 1; unsigned installedRAM = GetPhysicalmemory(); if(installedRAM < 2048264) { WARN("Machine has less than 2GB RAM."); } /* if(testDataFile("extractor.ini")) { ExtractorConfiguration extractorConfig("extractor.ini"); unsigned memoryAmountFromFile = atoi(extractorConfig.GetParameter("Memory").c_str()); if( memoryAmountFromFile != 0 && memoryAmountFromFile <= installedRAM/(1024*1024)) amountOfRAM = memoryAmountFromFile; INFO("Using " << amountOfRAM << " GB of RAM for buffers"); } */ StringMap stringMap; ExtractionContainers externalMemory; stringMap[""] = 0; extractCallBacks = new ExtractorCallbacks(&externalMemory, &stringMap); BaseParser<_Node, _RawRestrictionContainer, _Way> * parser; if(isPBF) { parser = new PBFParser(argv[1]); } else { parser = new XMLParser(argv[1]); } parser->RegisterCallbacks(&nodeFunction, &restrictionFunction, &wayFunction); parser->RegisterLUAState(myLuaState); if(!parser->Init()) INFO("Parser not initialized!"); parser->Parse(); externalMemory.PrepareData(outputFileName, restrictionsFileName, amountOfRAM); stringMap.clear(); delete parser; delete extractCallBacks; INFO("[extractor] finished."); std::cout << "\nRun:\n" "./osrm-prepare " << outputFileName << " " << restrictionsFileName << std::endl; return 0; }
void srvtimer_init(void) { INFO("timers initialization done"); }
int AmZRTP::init() { zrtp_log_set_log_engine(zrtp_log); AmConfigReader cfg; string cfgname=add2path(AmConfig::ModConfigPath, 1, "zrtp.conf"); if(cfg.loadFile(cfgname)) { ERROR("No %s config file present.\n", cfgname.c_str()); return -1; } cache_path = cfg.getParameter("cache_path"); if (cfg.hasParameter("zid_hex")) { string zid_hex = cfg.getParameter("zid_hex"); if (zid_hex.size() != 2*sizeof(zrtp_instance_zid)) { ERROR("zid_hex config parameter in zrtp.conf must be %lu characters long.\n", sizeof(zrtp_zid_t)*2); return -1; } for (size_t i=0;i<sizeof(zrtp_instance_zid);i++) { unsigned int h; if (reverse_hex2int(zid_hex.substr(i*2, 2), h)) { ERROR("in zid_hex in zrtp.conf: '%s' is no hex number\n", zid_hex.substr(i*2, 2).c_str()); return -1; } zrtp_instance_zid[i]=h % 0xff; } } else if (cfg.hasParameter("zid")) { string zid = cfg.getParameter("zid"); WARN("zid parameter in zrtp.conf is only supported for backwards compatibility. Please use zid_hex\n"); if (zid.length() != sizeof(zrtp_zid_t)) { ERROR("zid config parameter in zrtp.conf must be %lu characters long.\n", sizeof(zrtp_zid_t)); return -1; } for (size_t i=0;i<zid.length();i++) zrtp_instance_zid[i]=zid[i]; } else { // generate one string zid_hex; for (size_t i=0;i<sizeof(zrtp_instance_zid);i++) { zrtp_instance_zid[i]=get_random() % 0xff; zid_hex+=char2hex(zrtp_instance_zid[i], true); } WARN("Generated random ZID. To support key continuity through key cache " "on the peers, add this to zrtp.conf: 'zid_hex=\"%s\"'", zid_hex.c_str()); } DBG("initializing ZRTP library with cache path '%s'.\n", cache_path.c_str()); zrtp_config_defaults(&zrtp_config); strcpy(zrtp_config.client_id, SEMS_CLIENT_ID); memcpy((char*)zrtp_config.zid, (char*)zrtp_instance_zid, sizeof(zrtp_zid_t)); zrtp_config.lic_mode = ZRTP_LICENSE_MODE_UNLIMITED; strncpy(zrtp_config.cache_file_cfg.cache_path, cache_path.c_str(), 256); zrtp_config.cb.misc_cb.on_send_packet = AmZRTP::on_send_packet; zrtp_config.cb.event_cb.on_zrtp_secure = AmZRTP::on_zrtp_secure; zrtp_config.cb.event_cb.on_zrtp_security_event = AmZRTP::on_zrtp_security_event; zrtp_config.cb.event_cb.on_zrtp_protocol_event = AmZRTP::on_zrtp_protocol_event; if ( zrtp_status_ok != zrtp_init(&zrtp_config, &zrtp_global) ) { ERROR("Error during ZRTP initialization\n"); return -1; } size_t rand_bytes = cfg.getParameterInt("random_entropy_bytes", 172); if (rand_bytes) { INFO("adding %zd bytes entropy from /dev/random to ZRTP entropy pool\n", rand_bytes); FILE* fd = fopen("/dev/random", "r"); if (!fd) { ERROR("opening /dev/random for adding entropy to the pool\n"); return -1; } void* p = malloc(rand_bytes); if (p==NULL) return -1; size_t read_bytes = fread(p, 1, rand_bytes, fd); if (read_bytes != rand_bytes) { ERROR("reading %zd bytes from /dev/random\n", rand_bytes); return -1; } zrtp_entropy_add(zrtp_global, (const unsigned char*)p, read_bytes); free(p); } // zrtp_add_entropy(zrtp_global, NULL, 0); // fixme DBG("ZRTP initialized ok.\n"); return 0; }
/* * Verify that MPI_Offset exceeding 2**31 can be computed correctly. * Print any failure as information only, not as an error so that this * won't abort the remaining test or other separated tests. * * Test if MPIO can write file from under 2GB to over 2GB and then * from under 4GB to over 4GB. * Each process writes 1MB in round robin fashion. * Then reads the file back in by reverse order, that is process 0 * reads the data of process n-1 and vice versa. */ static int test_mpio_gb_file(char *filename) { int mpi_size, mpi_rank; MPI_Info info = MPI_INFO_NULL; int mrc; MPI_File fh; int i, j, n; int vrfyerrs; int writerrs; /* write errors */ int nerrs; int ntimes; /* how many times */ char *buf = NULL; char expected; MPI_Offset size; MPI_Offset mpi_off; MPI_Offset mpi_off_old; MPI_Status mpi_stat; struct stat stat_buf; int is_signed, sizeof_mpi_offset; nerrs = 0; /* set up MPI parameters */ MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); if (VERBOSE_MED) printf("MPI_Offset range test\n"); /* figure out the signness and sizeof MPI_Offset */ mpi_off = 0; is_signed = ((MPI_Offset)(mpi_off - 1)) < 0; sizeof_mpi_offset = (int)(sizeof(MPI_Offset)); /* * Verify the sizeof MPI_Offset and correctness of handling multiple GB * sizes. */ if (MAINPROCESS){ /* only process 0 needs to check it*/ printf("MPI_Offset is %s %d bytes integeral type\n", is_signed ? "signed" : "unsigned", (int)sizeof(MPI_Offset)); if (sizeof_mpi_offset <= 4 && is_signed){ printf("Skipped 2GB range test " "because MPI_Offset cannot support it\n"); }else { /* verify correctness of assigning 2GB sizes */ mpi_off = 2 * 1024 * (MPI_Offset)MB; INFO((mpi_off>0), "2GB OFFSET assignment no overflow"); INFO((mpi_off-1)==TWO_GB_LESS1, "2GB OFFSET assignment succeed"); /* verify correctness of increasing from below 2 GB to above 2GB */ mpi_off = TWO_GB_LESS1; for (i=0; i < 3; i++){ mpi_off_old = mpi_off; mpi_off = mpi_off + 1; /* no overflow */ INFO((mpi_off>0), "2GB OFFSET increment no overflow"); /* correct inc. */ INFO((mpi_off-1)==mpi_off_old, "2GB OFFSET increment succeed"); } } if (sizeof_mpi_offset <= 4){ printf("Skipped 4GB range test " "because MPI_Offset cannot support it\n"); }else { /* verify correctness of assigning 4GB sizes */ mpi_off = 4 * 1024 * (MPI_Offset)MB; INFO((mpi_off>0), "4GB OFFSET assignment no overflow"); INFO((mpi_off-1)==FOUR_GB_LESS1, "4GB OFFSET assignment succeed"); /* verify correctness of increasing from below 4 GB to above 4 GB */ mpi_off = FOUR_GB_LESS1; for (i=0; i < 3; i++){ mpi_off_old = mpi_off; mpi_off = mpi_off + 1; /* no overflow */ INFO((mpi_off>0), "4GB OFFSET increment no overflow"); /* correct inc. */ INFO((mpi_off-1)==mpi_off_old, "4GB OFFSET increment succeed"); } } } /* * Verify if we can write to a file of multiple GB sizes. */ if (VERBOSE_MED) printf("MPIO GB file test %s\n", filename); if (sizeof_mpi_offset <= 4){ printf("Skipped GB file range test " "because MPI_Offset cannot support it\n"); }else{ buf = malloc(MB); VRFY((buf!=NULL), "malloc succeed"); /* open a new file. Remove it first in case it exists. */ if (MAINPROCESS) remove(filename); MPI_Barrier(MPI_COMM_WORLD); /* prevent racing condition */ mrc = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE|MPI_MODE_RDWR, info, &fh); VRFY((mrc==MPI_SUCCESS), "MPI_FILE_OPEN"); printf("MPIO GB file write test %s\n", filename); /* instead of writing every bytes of the file, we will just write * some data around the 2 and 4 GB boundaries. That should cover * potential integer overflow and filesystem size limits. */ writerrs = 0; for (n=2; n <= 4; n+=2){ ntimes = GB/MB*n/mpi_size + 1; for (i=ntimes-2; i <= ntimes; i++){ mpi_off = (i*mpi_size + mpi_rank)*(MPI_Offset)MB; if (VERBOSE_MED) HDfprintf(stdout,"proc %d: write to mpi_off=%016llx, %lld\n", mpi_rank, mpi_off, mpi_off); /* set data to some trivial pattern for easy verification */ for (j=0; j<MB; j++) *(buf+j) = i*mpi_size + mpi_rank; if (VERBOSE_MED) HDfprintf(stdout,"proc %d: writing %d bytes at offset %lld\n", mpi_rank, MB, mpi_off); mrc = MPI_File_write_at(fh, mpi_off, buf, MB, MPI_BYTE, &mpi_stat); INFO((mrc==MPI_SUCCESS), "GB size file write"); if (mrc!=MPI_SUCCESS) writerrs++; } } /* close file and free the communicator */ mrc = MPI_File_close(&fh); VRFY((mrc==MPI_SUCCESS), "MPI_FILE_CLOSE"); mrc = MPI_Barrier(MPI_COMM_WORLD); VRFY((mrc==MPI_SUCCESS), "Sync after writes"); /* * Verify if we can read the multiple GB file just created. */ /* open it again to verify the data written */ /* but only if there was no write errors */ printf("MPIO GB file read test %s\n", filename); if (errors_sum(writerrs)>0){ printf("proc %d: Skip read test due to previous write errors\n", mpi_rank); goto finish; } mrc = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, info, &fh); VRFY((mrc==MPI_SUCCESS), ""); /* Only read back parts of the file that have been written. */ for (n=2; n <= 4; n+=2){ ntimes = GB/MB*n/mpi_size + 1; for (i=ntimes-2; i <= ntimes; i++){ mpi_off = (i*mpi_size + (mpi_size - mpi_rank - 1))*(MPI_Offset)MB; if (VERBOSE_MED) HDfprintf(stdout,"proc %d: read from mpi_off=%016llx, %lld\n", mpi_rank, mpi_off, mpi_off); mrc = MPI_File_read_at(fh, mpi_off, buf, MB, MPI_BYTE, &mpi_stat); INFO((mrc==MPI_SUCCESS), "GB size file read"); expected = i*mpi_size + (mpi_size - mpi_rank - 1); vrfyerrs=0; for (j=0; j<MB; j++){ if ((*(buf+j) != expected) && (vrfyerrs++ < MAX_ERR_REPORT || VERBOSE_MED)){ printf("proc %d: found data error at [%ld+%d], expect %d, got %d\n", mpi_rank, (long)mpi_off, j, expected, *(buf+j)); } } if (vrfyerrs > MAX_ERR_REPORT && !VERBOSE_MED) printf("proc %d: [more errors ...]\n", mpi_rank); nerrs += vrfyerrs; } } /* close file and free the communicator */ mrc = MPI_File_close(&fh); VRFY((mrc==MPI_SUCCESS), "MPI_FILE_CLOSE"); /* * one more sync to ensure all processes have done reading * before ending this test. */ mrc = MPI_Barrier(MPI_COMM_WORLD); VRFY((mrc==MPI_SUCCESS), "Sync before leaving test"); /* * Check if MPI_File_get_size works correctly. Some systems (only SGI Altix * Propack 4 so far) return wrong file size. It can be avoided by reconfiguring * with "--disable-mpi-size". */ #ifdef H5_HAVE_MPI_GET_SIZE printf("Test if MPI_File_get_size works correctly with %s\n", filename); mrc = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, info, &fh); VRFY((mrc==MPI_SUCCESS), ""); if (MAINPROCESS){ /* only process 0 needs to check it*/ mrc = MPI_File_get_size(fh, &size); VRFY((mrc==MPI_SUCCESS), ""); mrc=stat(filename, &stat_buf); VRFY((mrc==0), ""); /* Hopefully this casting is safe */ if(size != (MPI_Offset)(stat_buf.st_size)) { printf("Warning: MPI_File_get_size doesn't return correct file size. To avoid using it in the library, reconfigure and rebuild the library with --disable-mpi-size.\n"); } } /* close file and free the communicator */ mrc = MPI_File_close(&fh); VRFY((mrc==MPI_SUCCESS), "MPI_FILE_CLOSE"); /* * one more sync to ensure all processes have done reading * before ending this test. */ mrc = MPI_Barrier(MPI_COMM_WORLD); VRFY((mrc==MPI_SUCCESS), "Sync before leaving test"); #else printf("Skipped testing MPI_File_get_size because it's disabled\n"); #endif } finish: if (buf) HDfree(buf); return (nerrs); }
int main(int argc, char *argv[]) { LOGOG_INITIALIZE(); logog::Cout* logog_cout (new logog::Cout); BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); logog_cout->SetFormatter(*custom_format); TCLAP::CmdLine cmd("Simple mesh search test", ' ', "0.1"); // Define a value argument and add it to the command line. // A value arg defines a flag and a type of value that it expects, // such as "-m meshfile". TCLAP::ValueArg<std::string> mesh_arg("m","mesh","input mesh file",true,"test.msh","string"); // Add the argument mesh_arg to the CmdLine object. The CmdLine object // uses this Arg to parse the command line. cmd.add( mesh_arg ); TCLAP::ValueArg<unsigned> number_arg("n","number-of-test-points","the number of test points",true,10000,"positive number"); cmd.add( number_arg ); TCLAP::ValueArg<bool> contiguous_arg("c","use-contiguous-memory","use a contiguous memory for the test",false,true,"yes or no | 1 or 0"); cmd.add( contiguous_arg ); cmd.parse( argc, argv ); std::string fname (mesh_arg.getValue()); FileIO::Legacy::MeshIO mesh_io; #ifndef WIN32 BaseLib::MemWatch mem_watch; unsigned long mem_without_mesh (mem_watch.getVirtMemUsage()); #endif BaseLib::RunTime run_time; run_time.start(); MeshLib::Mesh* mesh (mesh_io.loadMeshFromFile(fname)); #ifndef WIN32 unsigned long mem_with_mesh (mem_watch.getVirtMemUsage()); INFO ("mem for mesh: %i MB", (mem_with_mesh - mem_without_mesh)/(1024*1024)); #endif INFO ("time for reading: %f s", run_time.elapsed()); // *** preparing test data std::vector<MeshLib::Node*> const& nodes(mesh->getNodes()); std::vector<GeoLib::Point*> pnts_for_search; unsigned n(std::min(static_cast<unsigned>(nodes.size()), number_arg.getValue())); for (size_t k(0); k<n; k++) { pnts_for_search.push_back(new GeoLib::Point(nodes[k])); } std::vector<size_t> idx_found_nodes; testMeshGridAlgorithm(mesh, pnts_for_search, idx_found_nodes, contiguous_arg.getValue()); for (size_t k(0); k<n; k++) { delete pnts_for_search[k]; } delete mesh; delete custom_format; delete logog_cout; LOGOG_SHUTDOWN(); }
void video_egl_clear_window() { video_egl_shutdown(); INFO( "Terminated EGL" ); }
void wlan_setup() { INFO("Virtual WLAN init"); }
int wlan_connect_init() { INFO("Virtual WLAN connecting"); return 0; }
/** * @brief transferFile * * writing data from server to local file * * \param source opened file for reading from * * \return int * \retval SUCCESS on Success * \retval ERROR on Error * */ static int transferFile(FILE *source) { char *fileName = NULL; unsigned long fileLength = 0; int result = 0; INFO("transferFile()", "get result from getOutputFileName() %s", ""); if ((result = getOutputFileName(source, &fileName)) != SUCCESS) return result; INFO("transferFile()", "get result from getOutputFileLength() %s", ""); if ((result = getOutputFileLength(source, &fileLength)) != SUCCESS) return result; errno = SUCCESS; INFO("transferFile()", "open outputFileDescriptor %s", ""); int outputFileDescriptor = open(fileName, O_WRONLY | O_CREAT | O_TRUNC, 0664); if (outputFileDescriptor == ERROR) { fprintf(stderr, "%s: transferFile()/open() failed: %s\n", programName, strerror(errno)); free(fileName); return ERROR; } INFO("transferFile()", "fdopen outputFile %s", ""); FILE *outputFile = fdopen(outputFileDescriptor, "w"); if (outputFile == NULL) { free(fileName); fprintf(stderr, "%s: transferFile()/fdopen() failed: %s\n", programName, strerror(errno)); return ERROR; } INFO("transferFile()", "opened %s for writing", fileName); free(fileName); size_t bytesAvailable = 0; size_t bytesWritten = 0; size_t bytesTransferred = 0; size_t bufferSize = 1; char buffer; INFO("transferFile()", "start writing bytes to outputFile %s", fileName); while ((bytesAvailable = fread(&buffer, (size_t)sizeof(char), bufferSize, source)) > 0) { bytesWritten = fwrite(&buffer, (size_t)sizeof(char), bytesAvailable, outputFile); if (bytesAvailable != bytesWritten) { fprintf(stderr, "%s: failed writing %zu bytes to file\n", programName, bytesAvailable); fclose(outputFile); return ERROR; } bytesTransferred += bytesWritten; if (bytesTransferred == fileLength) { INFO("transferFile()", "transferred %zu bytes to file", bytesTransferred); fclose(outputFile); return SUCCESS; } } fclose(outputFile); INFO("transferFile()", "closed %s", fileName); if (bytesTransferred < fileLength) { fprintf(stderr, "%s: missing bytes! received %zu out of %lu\n", programName, bytesTransferred, fileLength); return ERROR; } return SUCCESS; }
int main(int argc, const char * argv[]) { const char *server; const char *port; const char *user; const char *image_url; const char *message; programName = argv[0]; smc_parsecommandline(argc, argv, showUsage, &server, &port, &user, &message, &image_url, &verbose); INFO("main()", "Using the following options: server=\"%s\", port=\"%s\", user=\"%s\", img_url=\"%s\", message=\"%s\"", server, port, user, image_url, message); INFO("main()", "connecting to server=\"%s\", port=\"%s\"", server, port); int sfd = 0; if (connectToServer(server, port, &sfd) != SUCCESS) { fprintf(stderr, "%s: connectToServer() failed for server %s and port %s: %s\n", programName, server, port, strerror(errno)); exit(errno); } INFO("main()", "open file descriptor for writing %s", ""); errno = SUCCESS; FILE *toServer = fdopen(sfd, "w"); if (toServer == NULL) { fprintf(stderr, "%s: fdOpen() to write to server failed: %s\n", programName, strerror(errno)); close(sfd); exit(errno); } INFO("main()", "sending data to server %s", server); if (sendData(toServer, "user="******"%s: sendData() for param user=<user> failed: %s\n", programName, strerror(errno)); shutdown(sfd, SHUT_RDWR); fclose(toServer); exit(errno); } if (image_url != NULL) { INFO("main()", "found image, sending to server %s", server); if (sendData(toServer, "img=", image_url) == ERROR) { fprintf(stderr, "%s: sendData() for param img=<image_url> failed: %s\n", programName, strerror(errno)); shutdown(sfd, SHUT_RDWR); fclose(toServer); exit(errno); } } INFO("main()", "send message to server %s", server); if (sendData(toServer, "", message) == ERROR) { fprintf(stderr, "%s: sendData() for message failed: %s\n", programName, strerror(errno)); shutdown(sfd, SHUT_RDWR); fclose(toServer); exit(errno); } /* fclose schließt auch sfd, daher vorher ein dup */ INFO("main()", "creating backup of file descriptor %s", ""); int backupOfSfd = dup(sfd); INFO("main()", "closing connection to server %s", server); if (shutdown(sfd, SHUT_WR) != SUCCESS) { fprintf(stderr, "%s: shutDown() SHUT_WR for server connection failed: %s\n", programName, strerror(errno)); fclose(toServer); exit(EXIT_FAILURE); } INFO("main()", "closing file descriptor %s", ""); fclose(toServer); INFO("main()", "closed writing channel to server %s", server); INFO("main()", "open stream from server %s", server); FILE *fromServer = fdopen(backupOfSfd, "r"); if (fromServer == NULL) { fprintf(stderr, "%s: fdOpen() to read from server failed: %s\n", programName, strerror(errno)); close(backupOfSfd); exit(errno); } INFO("main()", "opened reading channel from server %s", server); /* read line for status=... */ /* if status returned from server != 0 then exit using the status */ int status = ERROR; INFO("main()", "start checking server response %s", ""); if (checkServerResponseStatus(fromServer, &status) != SUCCESS || status != SUCCESS) { fprintf(stderr, "%s: reading server response failed with error %d\n", programName, status); fclose(fromServer); close(backupOfSfd); exit(status); } INFO("main()", "server returned status %d", status); INFO("main()", "start receiving files from server %s", server); int canTransferFile = SUCCESS; while (canTransferFile != DONE) { canTransferFile = transferFile(fromServer); if (canTransferFile == ERROR) { fprintf(stderr, "%s: transferFile() failed: %s\n", programName, strerror(errno)); fclose(fromServer); close(backupOfSfd); exit(EXIT_FAILURE); } } INFO("main()", "received all data, closing connection to server %s", server); fclose(fromServer); close(backupOfSfd); INFO("main()", "closed connection to server %s", server); INFO("main()", "bye %s!", user); exit(status); }
int main(int argc, char **argv) { short http_port = 8080; char* http_addr = "0.0.0.0"; int arg; while( (arg = getopt(argc, argv, "b:p:r:d:h")) != -1) { switch(arg) { case 'b': http_addr = optarg; break; case 'p': http_port = atoi(optarg); break; case 'r': doc_root = optarg; case 'd': if(strcmp(optarg, "TRACE") == 0) OWL_ACTIVE_LOG_LEVEL = OWL_TRACE; else if(strcmp(optarg, "DEBUG") == 0) OWL_ACTIVE_LOG_LEVEL = OWL_DEBUG; else if(strcmp(optarg, "INFO") == 0) OWL_ACTIVE_LOG_LEVEL = OWL_INFO; else if(strcmp(optarg, "WARN") == 0) OWL_ACTIVE_LOG_LEVEL = OWL_WARNING; else OWL_ACTIVE_LOG_LEVEL = OWL_OFF; break; case 'h': default: usage(); exit(1); } } // Initialize application int status = 0; struct owl_state* state = malloc(sizeof(struct owl_state)); state->spotify_state = new_spotify_state(); state->state = OWL_STATE_NOT_STARTED; // Setup application handlers { state->event_base = event_base_new(); // Unix signal handlers state->sigint = evsignal_new(state->event_base, SIGINT, &sigint_handler, state); state->sigterm = evsignal_new(state->event_base, SIGTERM, &sigint_handler, state); state->sigsegv = evsignal_new(state->event_base, SIGSEGV, &sigint_handler, state); evsignal_add(state->sigint, NULL); evsignal_add(state->sigterm, NULL); evsignal_add(state->sigsegv, NULL); // Periodic callback state->timer = evtimer_new(state->event_base, &timer_handler, state); // Applications programatic callback state->app = evtimer_new(state->event_base, &timer_handler, state); // HTTP Server state->http = evhttp_new(state->event_base); evhttp_set_timeout(state->http, 60); evhttp_set_gencb(state->http, &http_handler, state); status = evhttp_bind_socket(state->http, http_addr, http_port); } if(status != 0) { ERROR("Could not bind owl server on IP (%s) or port (%d)\n", http_addr, http_port); goto shutdown; } status = initialize_spotify(state); if(status != 0) { ERROR("Could not initalize Spotify\n"); goto shutdown; } state->state = OWL_STATE_INITIALIZED; INFO("Owl started, connect to http://%s:%d\n", http_addr, http_port); // Kick off event loop event_base_dispatch(state->event_base); shutdown: INFO("Owl is shutting down\n"); event_free(state->sigint); event_free(state->sigterm); event_free(state->sigsegv); event_free(state->timer); evhttp_free(state->http); event_base_free(state->event_base); free_spotify_state(state->spotify_state); free(state); return status; }
struct lxc_handler *lxc_init(const char *name, struct lxc_conf *conf, const char *lxcpath) { int i; struct lxc_handler *handler; handler = malloc(sizeof(*handler)); if (!handler) return NULL; memset(handler, 0, sizeof(*handler)); handler->ttysock[0] = handler->ttysock[1] = -1; handler->conf = conf; handler->lxcpath = lxcpath; handler->pinfd = -1; for (i = 0; i < LXC_NS_MAX; i++) handler->nsfd[i] = -1; lsm_init(); handler->name = strdup(name); if (!handler->name) { ERROR("Failed to allocate memory."); goto out_free; } if (lxc_cmd_init(name, handler, lxcpath)) goto out_free_name; if (lxc_read_seccomp_config(conf) != 0) { ERROR("Failed loading seccomp policy."); goto out_close_maincmd_fd; } /* Begin by setting the state to STARTING. */ if (lxc_set_state(name, handler, STARTING)) { ERROR("Failed to set state for container \"%s\" to \"%s\".", name, lxc_state2str(STARTING)); goto out_close_maincmd_fd; } /* Start of environment variable setup for hooks. */ if (name && setenv("LXC_NAME", name, 1)) SYSERROR("Failed to set environment variable: LXC_NAME=%s.", name); if (conf->rcfile && setenv("LXC_CONFIG_FILE", conf->rcfile, 1)) SYSERROR("Failed to set environment variable: LXC_CONFIG_FILE=%s.", conf->rcfile); if (conf->rootfs.mount && setenv("LXC_ROOTFS_MOUNT", conf->rootfs.mount, 1)) SYSERROR("Failed to set environment variable: LXC_ROOTFS_MOUNT=%s.", conf->rootfs.mount); if (conf->rootfs.path && setenv("LXC_ROOTFS_PATH", conf->rootfs.path, 1)) SYSERROR("Failed to set environment variable: LXC_ROOTFS_PATH=%s.", conf->rootfs.path); if (conf->console.path && setenv("LXC_CONSOLE", conf->console.path, 1)) SYSERROR("Failed to set environment variable: LXC_CONSOLE=%s.", conf->console.path); if (conf->console.log_path && setenv("LXC_CONSOLE_LOGPATH", conf->console.log_path, 1)) SYSERROR("Failed to set environment variable: LXC_CONSOLE_LOGPATH=%s.", conf->console.log_path); if (setenv("LXC_CGNS_AWARE", "1", 1)) SYSERROR("Failed to set environment variable LXC_CGNS_AWARE=1."); /* End of environment variable setup for hooks. */ if (run_lxc_hooks(name, "pre-start", conf, handler->lxcpath, NULL)) { ERROR("Failed to run lxc.hook.pre-start for container \"%s\".", name); goto out_aborting; } /* The signal fd has to be created before forking otherwise if the child * process exits before we setup the signal fd, the event will be lost * and the command will be stuck. */ handler->sigfd = setup_signal_fd(&handler->oldmask); if (handler->sigfd < 0) { ERROR("Failed to setup SIGCHLD fd handler."); goto out_delete_tty; } /* Do this after setting up signals since it might unblock SIGWINCH. */ if (lxc_console_create(conf)) { ERROR("Failed to create console for container \"%s\".", name); goto out_restore_sigmask; } if (ttys_shift_ids(conf) < 0) { ERROR("Failed to shift tty into container."); goto out_restore_sigmask; } INFO("Container \"%s\" is initialized.", name); return handler; out_restore_sigmask: sigprocmask(SIG_SETMASK, &handler->oldmask, NULL); out_delete_tty: lxc_delete_tty(&conf->tty_info); out_aborting: lxc_set_state(name, handler, ABORTING); out_close_maincmd_fd: close(conf->maincmd_fd); conf->maincmd_fd = -1; out_free_name: free(handler->name); handler->name = NULL; out_free: free(handler); return NULL; }
static int tss2_read_vserver (vserver_list_t *vserver) { /* * Poll information for the given vserver and submit it to collect. * If vserver is NULL the global server information will be queried. */ int status; gauge_t users = NAN; gauge_t channels = NAN; gauge_t servers = NAN; counter_t rx_octets = 0; counter_t tx_octets = 0; counter_t rx_packets = 0; counter_t tx_packets = 0; gauge_t packet_loss = NAN; int valid = 0; char plugin_instance[DATA_MAX_NAME_LEN]; FILE *read_fh; FILE *write_fh; /* Get the send/receive sockets */ status = tss2_get_socket (&read_fh, &write_fh); if (status != 0) { ERROR ("teamspeak2 plugin: tss2_get_socket failed."); return (-1); } if (vserver == NULL) { /* Request global information */ memset (plugin_instance, 0, sizeof (plugin_instance)); status = tss2_send_request (write_fh, "gi\r\n"); } else { /* Request server information */ ssnprintf (plugin_instance, sizeof (plugin_instance), "vserver%i", vserver->port); /* Select the server */ status = tss2_select_vserver (read_fh, write_fh, vserver); if (status != 0) return (status); status = tss2_send_request (write_fh, "si\r\n"); } if (status != 0) { ERROR ("teamspeak2 plugin: tss2_send_request failed."); return (-1); } /* Loop until break */ while (42) { char buffer[4096]; char *key; char *value; char *endptr = NULL; /* Read one line of the server's answer */ status = tss2_receive_line (read_fh, buffer, sizeof (buffer)); if (status != 0) { /* Set to NULL just to make sure noone uses these FHs anymore. */ read_fh = NULL; write_fh = NULL; ERROR ("teamspeak2 plugin: tss2_receive_line failed."); break; } if (strncasecmp ("ERROR", buffer, 5) == 0) { ERROR ("teamspeak2 plugin: Server returned an error: %s", buffer); break; } else if (strncasecmp ("OK", buffer, 2) == 0) { break; } /* Split line into key and value */ key = strchr (buffer, '_'); if (key == NULL) { DEBUG ("teamspeak2 plugin: Cannot parse line: %s", buffer); continue; } key++; /* Evaluate assignment */ value = strchr (key, '='); if (value == NULL) { DEBUG ("teamspeak2 plugin: Cannot parse line: %s", buffer); continue; } *value = 0; value++; /* Check for known key and save the given value */ /* global info: users_online, * server info: currentusers. */ if ((strcmp ("currentusers", key) == 0) || (strcmp ("users_online", key) == 0)) { users = strtod (value, &endptr); if (value != endptr) valid |= 0x01; } /* global info: channels, * server info: currentchannels. */ else if ((strcmp ("currentchannels", key) == 0) || (strcmp ("channels", key) == 0)) { channels = strtod (value, &endptr); if (value != endptr) valid |= 0x40; } /* global only */ else if (strcmp ("servers", key) == 0) { servers = strtod (value, &endptr); if (value != endptr) valid |= 0x80; } else if (strcmp ("bytesreceived", key) == 0) { rx_octets = strtoll (value, &endptr, 0); if (value != endptr) valid |= 0x02; } else if (strcmp ("bytessend", key) == 0) { tx_octets = strtoll (value, &endptr, 0); if (value != endptr) valid |= 0x04; } else if (strcmp ("packetsreceived", key) == 0) { rx_packets = strtoll (value, &endptr, 0); if (value != endptr) valid |= 0x08; } else if (strcmp ("packetssend", key) == 0) { tx_packets = strtoll (value, &endptr, 0); if (value != endptr) valid |= 0x10; } else if ((strncmp ("allow_codec_", key, strlen ("allow_codec_")) == 0) || (strncmp ("bwinlast", key, strlen ("bwinlast")) == 0) || (strncmp ("bwoutlast", key, strlen ("bwoutlast")) == 0) || (strncmp ("webpost_", key, strlen ("webpost_")) == 0) || (strcmp ("adminemail", key) == 0) || (strcmp ("clan_server", key) == 0) || (strcmp ("countrynumber", key) == 0) || (strcmp ("id", key) == 0) || (strcmp ("ispname", key) == 0) || (strcmp ("linkurl", key) == 0) || (strcmp ("maxusers", key) == 0) || (strcmp ("name", key) == 0) || (strcmp ("password", key) == 0) || (strcmp ("platform", key) == 0) || (strcmp ("server_platform", key) == 0) || (strcmp ("server_uptime", key) == 0) || (strcmp ("server_version", key) == 0) || (strcmp ("udpport", key) == 0) || (strcmp ("uptime", key) == 0) || (strcmp ("users_maximal", key) == 0) || (strcmp ("welcomemessage", key) == 0)) /* ignore */; else { INFO ("teamspeak2 plugin: Unknown key-value-pair: " "key = %s; value = %s;", key, value); } } /* while (42) */ /* Collect vserver packet loss rates only if the loop above did not exit * with an error. */ if ((status == 0) && (vserver != NULL)) { status = tss2_vserver_gapl (read_fh, write_fh, &packet_loss); if (status == 0) { valid |= 0x20; } else { WARNING ("teamspeak2 plugin: Reading package loss " "for vserver %i failed.", vserver->port); } } if ((valid & 0x01) == 0x01) tss2_submit_gauge (plugin_instance, "users", NULL, users); if ((valid & 0x06) == 0x06) tss2_submit_io (plugin_instance, "io_octets", rx_octets, tx_octets); if ((valid & 0x18) == 0x18) tss2_submit_io (plugin_instance, "io_packets", rx_packets, tx_packets); if ((valid & 0x20) == 0x20) tss2_submit_gauge (plugin_instance, "percent", "packet_loss", packet_loss); if ((valid & 0x40) == 0x40) tss2_submit_gauge (plugin_instance, "gauge", "channels", channels); if ((valid & 0x80) == 0x80) tss2_submit_gauge (plugin_instance, "gauge", "servers", servers); if (valid == 0) return (-1); return (0); } /* int tss2_read_vserver */
void CommandService::_process_respond(Command* rpc_res){ const int64_t who =static_cast<int64_t>(rpc_res->getWho()); const int64_t rpc_id =static_cast<int64_t>(rpc_res->getSn()); do{ RpcInfo* rpc =_get_rpc(rpc_id); if(rpc == 0){ WARN("service %s(%lld) who %lld rpc %lld respond, not exist", name(), (long long)m_id, (long long)who, (long long)rpc_id); break; } if(Command* cmd=rpc->getCommand()){ // check & prepare command Array* queue =static_cast< Array* >(m_queue_tb->get(who)); if(queue == 0){ WARN("service %s(%lld) who %lld rpc %lld respond, command not exist", name(), (long long)m_id, (long long)who, (long long)rpc_id); break; } Command* front =static_cast< Command* >(queue->front()); if(!front){ WARN("service %s(%lld) who %lld rpc %lld respond, command not exist", name(), (long long)m_id, (long long)who, (long long)rpc_id); break; } if(front != cmd){ WARN("service %s(%lld) who %lld rpc %lld respond, command mismatch", name(), (long long)m_id, (long long)who, (long long)rpc_id); break; } // call rpc m_processing_command =front; const int64_t result =rpc->invoke(rpc_res); m_processing_command =0; // process result const int64_t cmd_id =front->getCommand(); if(result == Command::STATE_COMPLETE){ front->setState(Command::STATE_COMPLETE); queue->pop_front(); INFO("service %s(%lld) who %lld rpc %lld respond, command %lld complete", name(), (long long)m_id, (long long)who, (long long)rpc_id, (long long)cmd_id); } else if(result > 0){ front->setState(Command::STATE_PROCESSING); INFO("service %s(%lld) who %lld rpc %lld respond, command %lld processing", name(), (long long)m_id, (long long)who, (long long)rpc_id, (long long)cmd_id); } else{ front->setState(Command::STATE_ERROR); queue->pop_front(); ERROR("service %s(%lld) who %lld rpc %lld respond, command %lld error %lld", name(), (long long)m_id, (long long)who, (long long)rpc_id, (long long)cmd_id, (long long)result); } // post process if(cmd_id==LOGOUT_REQUEST && queue->empty()){ m_queue_tb->remove(who); } else if(queue->size()){ _process_request(who); } } else{ const int64_t result =rpc->invoke(rpc_res); if(result == Command::STATE_COMPLETE){ INFO("service %s(%lld) who %lld rpc %lld respond, complete", name(), (long long)m_id, (long long)who, (long long)rpc_id); } else if(result > 0){ INFO("service %s(%lld) who %lld rpc %lld respond, processing", name(), (long long)m_id, (long long)who, (long long)rpc_id); } else{ ERROR("service %s(%lld) who %lld rpc %lld respond, error %lld", name(), (long long)m_id, (long long)who, (long long)rpc_id, (long long)result); } } }while(0); // remove rpc info m_rpc_tb->remove(rpc_id); }
wlan_result_t wlan_activate() { INFO("Virtual WLAN on"); return 0; }
void testMeshGridAlgorithm(MeshLib::Mesh const*const mesh, std::vector<GeoLib::Point*>& pnts_for_search, std::vector<size_t> &idx_found_nodes, bool contiguous) { // constructing Grid INFO ("[MeshGridAlgorithm] constructing mesh grid object ..."); if (contiguous) { std::vector<MeshLib::Node> mesh_nodes; size_t n_nodes(mesh->getNodes().size()); mesh_nodes.reserve(n_nodes); for (size_t k(0); k<n_nodes; k++) { mesh_nodes.push_back(MeshLib::Node(*(mesh->getNodes()[k]))); } #ifndef WIN32 BaseLib::MemWatch mem_watch; unsigned long mem_without_mesh (mem_watch.getVirtMemUsage()); #endif clock_t start_grid_construction = clock(); GeoLib::Grid<MeshLib::Node> mesh_grid(mesh_nodes.begin(), mesh_nodes.end(), 511); clock_t end_grid_construction = clock(); #ifndef WIN32 unsigned long mem_with_mesh (mem_watch.getVirtMemUsage()); #endif INFO("\tdone, construction time: %f seconds", (end_grid_construction-start_grid_construction)/(double)(CLOCKS_PER_SEC)); #ifndef WIN32 INFO ("[MeshGridAlgorithm] mem for mesh grid: %i MB", (mem_with_mesh - mem_without_mesh)/(1024*1024)); #endif const size_t n_pnts_for_search(pnts_for_search.size()); INFO ("[MeshGridAlgorithm] searching %d points ...", pnts_for_search.size()); clock_t start = clock(); for (size_t k(0); k<n_pnts_for_search; k++) { MeshLib::Node const* node(mesh_grid.getNearestPoint(*pnts_for_search[k])); idx_found_nodes.push_back(node->getID()); } clock_t stop = clock(); INFO("\tdone, search time: %f seconds", (stop-start)/(double)(CLOCKS_PER_SEC)); } else { #ifndef WIN32 BaseLib::MemWatch mem_watch; unsigned long mem_without_mesh (mem_watch.getVirtMemUsage()); #endif clock_t start_grid_construction = clock(); GeoLib::Grid<MeshLib::Node> mesh_grid(mesh->getNodes().begin(), mesh->getNodes().end(), 511); clock_t end_grid_construction = clock(); #ifndef WIN32 unsigned long mem_with_mesh (mem_watch.getVirtMemUsage()); #endif INFO("\tdone, construction time: %f seconds", (end_grid_construction-start_grid_construction)/(double)(CLOCKS_PER_SEC)); #ifndef WIN32 INFO ("[MeshGridAlgorithm] mem for mesh grid: %i MB", (mem_with_mesh - mem_without_mesh)/(1024*1024)); #endif const size_t n_pnts_for_search(pnts_for_search.size()); INFO ("[MeshGridAlgorithm] searching %d points ...", pnts_for_search.size()); clock_t start = clock(); for (size_t k(0); k<n_pnts_for_search; k++) { MeshLib::Node const* node(mesh_grid.getNearestPoint(pnts_for_search[k])); idx_found_nodes.push_back(node->getID()); } clock_t stop = clock(); INFO("\tdone, search time: %f seconds", (stop-start)/(double)(CLOCKS_PER_SEC)); } }
wlan_result_t wlan_deactivate() { INFO("Virtual WLAN off"); return 0; }
void StandardExtension::initOptions() { HHVM_FE(assert_options); HHVM_FE(assert); HHVM_FE(dl); HHVM_FE(extension_loaded); HHVM_FE(get_loaded_extensions); HHVM_FE(get_extension_funcs); HHVM_FE(get_cfg_var); HHVM_FE(get_current_user); HHVM_FE(get_defined_constants); HHVM_FE(get_include_path); HHVM_FE(restore_include_path); HHVM_FE(set_include_path); HHVM_FE(get_included_files); HHVM_FE(inclued_get_data); HHVM_FE(get_magic_quotes_gpc); HHVM_FE(get_magic_quotes_runtime); HHVM_FE(getenv); HHVM_FE(getlastmod); HHVM_FE(getmygid); HHVM_FE(getmyinode); HHVM_FE(getmypid); HHVM_FE(getmyuid); HHVM_FE(getopt); HHVM_FE(getrusage); HHVM_FE(clock_getres); HHVM_FE(clock_gettime); HHVM_FE(clock_settime); HHVM_FE(cpu_get_count); HHVM_FE(cpu_get_model); HHVM_FE(ini_get); HHVM_FE(ini_get_all); HHVM_FE(ini_restore); HHVM_FE(ini_set); HHVM_FE(memory_get_peak_usage); HHVM_FE(memory_get_usage); // This is HH-specific as well but code depends on the old name. HHVM_FE(memory_get_allocation); HHVM_FE(hphp_memory_get_interval_peak_usage); HHVM_FE(hphp_memory_start_interval); HHVM_FE(hphp_memory_stop_interval); HHVM_FE(php_ini_loaded_file); HHVM_FE(php_sapi_name); HHVM_FE(php_uname); HHVM_FE(phpinfo); HHVM_FE(phpversion); HHVM_FE(putenv); HHVM_FE(set_magic_quotes_runtime); HHVM_FE(set_time_limit); HHVM_FE(sys_get_temp_dir); HHVM_FE(zend_version); HHVM_FE(version_compare); HHVM_FE(gc_enabled); HHVM_FE(gc_enable); HHVM_FE(gc_disable); HHVM_FE(gc_collect_cycles); #define INFO(v) Native::registerConstant<KindOfInt64> \ (makeStaticString("INFO_" #v), k_INFO_##v); INFO(GENERAL); INFO(CREDITS); INFO(CONFIGURATION); INFO(MODULES); INFO(ENVIRONMENT); INFO(VARIABLES); INFO(LICENSE); INFO(ALL); #undef INFO #define ASSERTCONST(v) Native::registerConstant<KindOfInt64> \ (makeStaticString("ASSERT_" #v), k_ASSERT_##v); ASSERTCONST(ACTIVE); ASSERTCONST(CALLBACK); ASSERTCONST(BAIL); ASSERTCONST(WARNING); ASSERTCONST(QUIET_EVAL); #undef ASSERTCONST loadSystemlib("std_options"); }
wlan_result_t wlan_disconnect_now() { INFO("Virtual WLAN disconnected"); return 0; }
int sync_run(sync_t *q, cf_t *input) { int N_id_2, peak_pos[3], sss_idx_n, sss_idx_e; int m0, m1; float m0_value_e, m1_value_e,m0_value_n, m1_value_n; int slot_id_e, N_id_1_e, slot_id_n, N_id_1_n; float peak_value[3]; float mean_value[3]; float max=-999; int i; int peak_detected; if (q->force_N_id_2 == -1) { for (N_id_2=0;N_id_2<3;N_id_2++) { peak_pos[N_id_2] = pss_synch_find_pss(&q->pss[N_id_2], input, &peak_value[N_id_2], &mean_value[N_id_2]); } for (i=0;i<3;i++) { if (peak_value[i] > max) { max = peak_value[i]; N_id_2 = i; } } } else { N_id_2 = q->force_N_id_2; peak_pos[N_id_2] = pss_synch_find_pss(&q->pss[N_id_2], input, &peak_value[N_id_2], &mean_value[N_id_2]); } q->peak_to_avg = peak_value[N_id_2] / mean_value[N_id_2]; DEBUG("PSS possible peak N_id_2=%d, pos=%d peak=%.2f par=%.2f threshold=%.2f\n", N_id_2, peak_pos[N_id_2], peak_value[N_id_2], q->peak_to_avg, q->threshold); /* If peak detected */ peak_detected = 0; if (peak_pos[N_id_2] - 128 >= 0) { if (q->pss_mode == ABSOLUTE) { if (peak_value[N_id_2] > q->threshold) { peak_detected = 1; } } else { if (q->peak_to_avg > q->threshold) { peak_detected = 1; } } } if (peak_detected) { q->cfo = pss_synch_cfo_compute(&q->pss[N_id_2], &input[peak_pos[N_id_2]-128]); INFO("PSS peak detected N_id_2=%d, pos=%d peak=%.2f par=%.2f th=%.2f cfo=%.4f\n", N_id_2, peak_pos[N_id_2], peak_value[N_id_2], q->peak_to_avg, q->threshold, q->cfo); if (q->sss_en) { /* Make sure we have enough room to find SSS sequence */ sss_idx_n = peak_pos[N_id_2]-2*(128+CP(128,CPNORM_LEN)); sss_idx_e = peak_pos[N_id_2]-2*(128+CP(128,CPEXT_LEN)); if (q->detect_cp) { if (sss_idx_n < 0 || sss_idx_e < 0) { INFO("Not enough room to decode SSS (%d, %d)\n", sss_idx_n, sss_idx_e); return -1; } } else { if (CP_ISNORM(q->cp)) { if (sss_idx_n < 0) { INFO("Not enough room to decode SSS (%d)\n", sss_idx_n); return -1; } } else { if (sss_idx_e < 0) { INFO("Not enough room to decode SSS (%d)\n", sss_idx_e); return -1; } } } N_id_1_e = -1; N_id_1_n = -1; slot_id_e = -1; slot_id_n = -1; /* try Normal CP length */ if (q->detect_cp || CP_ISNORM(q->cp)) { sss_synch_m0m1(&q->sss[N_id_2], &input[sss_idx_n], &m0, &m0_value_n, &m1, &m1_value_n); slot_id_n = 2 * sss_synch_subframe(m0, m1); N_id_1_n = sss_synch_N_id_1(&q->sss[N_id_2], m0, m1); } if (q->detect_cp || CP_ISEXT(q->cp)) { /* Now try Extended CP length */ sss_synch_m0m1(&q->sss[N_id_2], &input[sss_idx_e], &m0, &m0_value_e, &m1, &m1_value_e); slot_id_e = 2 * sss_synch_subframe(m0, m1); N_id_1_e = sss_synch_N_id_1(&q->sss[N_id_2], m0, m1); } /* Correlation with extended CP hypoteshis is greater than with normal? */ if ((q->detect_cp && m0_value_e * m1_value_e > m0_value_n * m1_value_n) || CP_ISEXT(q->cp)) { q->cp = CPEXT; q->slot_id = slot_id_e; q->N_id_1 = N_id_1_e; /* then is normal CP */ } else { q->cp = CPNORM; q->slot_id = slot_id_n; q->N_id_1 = N_id_1_n; } q->N_id_2 = N_id_2; INFO("SSS detected N_id_1=%d, slot_idx=%d, %s CP\n", q->N_id_1, q->slot_id, CP_ISNORM(q->cp)?"Normal":"Extended"); } return peak_pos[N_id_2]; } else { return -1; } }
static void __exit aml_sysled_exit(void) { INFO("module exit\n"); platform_driver_unregister(&aml_sysled_driver); }
/* * create a cgroup for the container in a particular subsystem. */ static int lxc_one_cgroup_create(const char *name, struct mntent *mntent, pid_t pid) { char cginit[MAXPATHLEN], cgname[MAXPATHLEN], cgparent[MAXPATHLEN]; char clonechild[MAXPATHLEN]; char initcgroup[MAXPATHLEN]; int flags, ret; /* cgparent is the parent dir, e.g., /sys/fs/cgroup/<cgroup>/<init-cgroup>/lxc */ /* (remember get_init_cgroup() returns a path starting with '/') */ /* cgname is the full name, e.g., /sys/fs/cgroup/<cgroup>/<init-cgroup>/lxc/name */ ret = snprintf(cginit, MAXPATHLEN, "%s%s", mntent->mnt_dir, get_init_cgroup(NULL, mntent, initcgroup)); if (ret < 0 || ret >= MAXPATHLEN) { SYSERROR("Failed creating pathname for init's cgroup (%d)\n", ret); return -1; } flags = get_cgroup_flags(mntent); ret = snprintf(cgparent, MAXPATHLEN, "%s%s", cginit, (flags & CGROUP_NS_CGROUP) ? "" : "/lxc"); if (ret < 0 || ret >= MAXPATHLEN) { SYSERROR("Failed creating pathname for cgroup parent (%d)\n", ret); return -1; } ret = snprintf(cgname, MAXPATHLEN, "%s/%s", cgparent, name); if (ret < 0 || ret >= MAXPATHLEN) { SYSERROR("Failed creating pathname for cgroup (%d)\n", ret); return -1; } /* Do we have the deprecated ns_cgroup subsystem? */ if (flags & CGROUP_NS_CGROUP) { WARN("using deprecated ns_cgroup"); return cgroup_rename_nsgroup(cginit, name, pid); } ret = snprintf(clonechild, MAXPATHLEN, "%s/cgroup.clone_children", cginit); if (ret < 0 || ret >= MAXPATHLEN) { SYSERROR("Failed creating pathname for clone_children (%d)\n", ret); return -1; } /* we check if the kernel has clone_children, at this point if there * no clone_children neither ns_cgroup, that means the cgroup is mounted * without the ns_cgroup and it has not the compatibility flag */ if (access(clonechild, F_OK)) { ERROR("no ns_cgroup option specified"); return -1; } /* enable the clone_children flag of the cgroup */ if (cgroup_enable_clone_children(clonechild)) { SYSERROR("failed to enable 'clone_children flag"); return -1; } /* if cgparent does not exist, create it */ if (access(cgparent, F_OK) && mkdir(cgparent, 0755)) { SYSERROR("failed to create '%s' directory", cgparent); return -1; } /* * There is a previous cgroup. Try to delete it. If that fails * (i.e. it is not empty) try to move it out of the way. */ if (!access(cgname, F_OK) && rmdir(cgname)) { if (try_to_move_cgname(cgparent, cgname)) { SYSERROR("failed to remove previous cgroup '%s'", cgname); return -1; } } /* Let's create the cgroup */ if (mkdir(cgname, 0755)) { SYSERROR("failed to create '%s' directory", cgname); return -1; } INFO("created cgroup '%s'", cgname); return 0; }
void runAWSClient(void) { IoT_Error_t rc = NONE_ERROR; MQTTClient_t mqttClient; aws_iot_mqtt_init(&mqttClient); ShadowParameters_t sp = ShadowParametersDefault; sp.pMyThingName = AWS_IOT_MY_THING_NAME; sp.pMqttClientId = AWS_IOT_MQTT_CLIENT_ID; sp.pHost = HostAddress; sp.port = port; sp.pClientCRT = AWS_IOT_CERTIFICATE_FILENAME; sp.pClientKey = AWS_IOT_PRIVATE_KEY_FILENAME; sp.pRootCA = AWS_IOT_ROOT_CA_FILENAME; INFO("Shadow Init"); rc = aws_iot_shadow_init(&mqttClient); if (NONE_ERROR != rc) { ERROR("Shadow Connection Error"); return; } INFO("Shadow Connect"); rc = aws_iot_shadow_connect(&mqttClient, &sp); if (NONE_ERROR != rc) { ERROR("Shadow Connection Error"); return; } jsonStruct_t deltaObject; deltaObject.pData = stringToEchoDelta; deltaObject.pKey = "state"; deltaObject.type = SHADOW_JSON_OBJECT; deltaObject.cb = DeltaCallback; /* * Register the jsonStruct object */ rc = aws_iot_shadow_register_delta(&mqttClient, &deltaObject); /* Now wait in the loop to receive any message sent from the console */ while (rc == NONE_ERROR) { /* * Lets check for the incoming messages for 200 ms. */ rc = aws_iot_shadow_yield(&mqttClient, 200); if (messageArrivedOnDelta) { INFO("\nSending delta message back %s\n", stringToEchoDelta); rc = aws_iot_shadow_update(&mqttClient, AWS_IOT_MY_THING_NAME, stringToEchoDelta, UpdateStatusCallback, NULL, 2, true); messageArrivedOnDelta = false; } /* sleep for some time in seconds */ Task_sleep(1000); } if (NONE_ERROR != rc) { ERROR("An error occurred in the loop %d", rc); } INFO("Disconnecting"); rc = aws_iot_shadow_disconnect(&mqttClient); if (NONE_ERROR != rc) { ERROR("Disconnect error %d", rc); } }
int main (int argc, char * argv[]) { FishSoundInfo fsinfo; const FishSoundComment * comment, * comment2; FishSoundComment mycomment; int err; fsinfo.samplerate = 16000; fsinfo.channels = 1; /* The format doesn't really matter as we're not actually * going to encode any audio, so just ensure we can * set this to something that's configured. */ #if HAVE_VORBIS fsinfo.format = FISH_SOUND_VORBIS; #elif HAVE_SPEEX fsinfo.format = FISH_SOUND_SPEEX; #else fsinfo.format = FISH_SOUND_FLAC; #endif #if FS_ENCODE INFO ("Initializing FishSound for comments (encode)"); fsound = fish_sound_new (FISH_SOUND_ENCODE, &fsinfo); INFO ("+ Adding ARTIST1 byname"); err = fish_sound_comment_add_byname (fsound, "ARTIST", ARTIST1); if (err < 0) FAIL ("Operation failed"); INFO ("+ Adding COPYRIGHT byname"); err = fish_sound_comment_add_byname (fsound, "COPYRIGHT", COPYRIGHT); if (err < 0) FAIL ("Operation failed"); INFO ("+ Retrieving first (expect ARTIST1)"); comment = fish_sound_comment_first (fsound); if (comment == NULL) FAIL ("Recently inserted ARTIST1 not retrieved"); if (strcmp (comment->name, "ARTIST")) FAIL ("Incorrect ARTIST1 name found"); if (strcmp (comment->value, ARTIST1)) FAIL ("Incorrect ARTIST1 value found"); INFO ("+ Retrieving next (expect COPYRIGHT)"); comment = fish_sound_comment_next (fsound, comment); if (comment == NULL) FAIL ("Recently inserted COPYRIGHT not retrieved"); if (strcmp (comment->name, "COPYRIGHT")) FAIL ("Incorrect COPYRIGHT name found"); if (strcmp (comment->value, COPYRIGHT)) FAIL ("Incorrect COPYRIGHT value found"); INFO ("+ Checking comments termination"); comment2 = fish_sound_comment_next (fsound, comment); if (comment2 != NULL) FAIL ("Comments unterminated"); INFO ("+ Adding LICENSE from local storage"); mycomment.name = "LICENSE"; mycomment.value = LICENSE; err = fish_sound_comment_add (fsound, &mycomment); if (err < 0) FAIL ("Operation failed"); INFO ("+ Retrieving next (expect LICENSE)"); comment = fish_sound_comment_next (fsound, comment); if (comment == NULL) FAIL ("Recently inserted LICENSE not retrieved"); if (comment == &mycomment) FAIL ("Recently inserted LICENSE not restored"); if (strcmp (comment->name, "LICENSE")) FAIL ("Incorrect LICENSE name found"); if (strcmp (comment->value, LICENSE)) FAIL ("Incorrect LICENSE value found"); INFO ("+ Testing add of valid plain (not key=value) COMMENT byname"); err = fish_sound_comment_add_byname (fsound, COMMENT, NULL); if (err < 0) FAIL ("Operation failed"); INFO ("+ Testing add of valid plain (not key=value) COMMENT from local storage"); mycomment.name = COMMENT; mycomment.value = NULL; err = fish_sound_comment_add (fsound, &mycomment); if (err < 0) FAIL ("Operation failed"); INFO ("+ Adding ARTIST2 byname"); err = fish_sound_comment_add_byname (fsound, "ARTIST", ARTIST2); if (err < 0) FAIL ("Operation failed"); INFO ("+ Retrieving first ARTIST using wierd caps (expect ARTIST1)"); comment = fish_sound_comment_first_byname (fsound, "ArTiSt"); if (comment == NULL) FAIL ("Recently inserted ARTIST1 not retrieved"); if (strcmp (comment->name, "ARTIST")) FAIL ("Incorrect ARTIST1 name found"); if (strcmp (comment->value, ARTIST1)) FAIL ("Incorrect ARTIST1 value found"); INFO ("+ Retrieving next ARTIST (expect ARTIST2)"); comment = fish_sound_comment_next_byname (fsound, comment); if (comment == NULL) FAIL ("Recently inserted ARTIST2 not retrieved"); if (strcmp (comment->name, "ARTIST")) FAIL ("Incorrect ARTIST2 name found"); if (strcmp (comment->value, ARTIST2)) FAIL ("Incorrect ARTIST2 value found"); INFO ("+ Removing LICENSE byname"); err = fish_sound_comment_remove_byname (fsound, "LICENSE"); if (err != 1) FAIL ("Operation failed"); INFO ("+ Attempting to retrieve LICENSE"); comment = fish_sound_comment_first_byname (fsound, "LICENSE"); if (comment != NULL) FAIL ("Removed comment incorrectly retrieved"); INFO ("+ Removing COPYRIGHT from local storage"); mycomment.name = "COPYRIGHT"; mycomment.value = COPYRIGHT; err = fish_sound_comment_remove (fsound, &mycomment); if (err != 1) FAIL ("Operation failed"); INFO ("+ Attempting to retrieve COPYRIGHT"); comment = fish_sound_comment_first_byname (fsound, "COPYRIGHT"); if (comment != NULL) FAIL ("Removed comment incorrectly retrieved"); INFO ("Deleting FishSound (encode)"); fish_sound_delete (fsound); #endif /* FS_ENCODE */ #if FS_DECODE INFO ("Initializing FishSound for comments (decode)"); fsound = fish_sound_new (FISH_SOUND_DECODE, &fsinfo); INFO ("+ Adding ARTIST1 byname (invalid for decode)"); err = fish_sound_comment_add_byname (fsound, "ARTIST", ARTIST1); if (err == 0) FAIL ("Operation disallowed"); INFO ("+ Removing ARTIST byname (invalid for decode)"); err = fish_sound_comment_remove_byname (fsound, "ARTIST"); if (err == 0) FAIL ("Operation disallowed"); INFO ("Deleteing FishSound (decode)"); fish_sound_delete (fsound); #endif exit (0); }
void zrtp_play_alert(zrtp_stream_ctx_t* ctx) { INFO("zrtp_play_alert: ALERT!\n"); ctx->need_play_alert = zrtp_play_no; }
QString transform(const QString &pat, const QString &tss, const QVector<const char *> ¶ms) { QString parsed; INFO(i18n("Parsing stylesheet")); #if defined (SIMPLE_XSLT) && defined(Q_OS_WIN) // prepare use of local available dtd versions instead of fetching every time from the internet // this approach is url based if (!defaultEntityLoader) { defaultEntityLoader = xmlGetExternalEntityLoader(); xmlSetExternalEntityLoader(xsltprocExternalEntityLoader); replaceURLList[QLatin1String("http://www.oasis-open.org/docbook/xml/4.5")] = QString("file:///%1").arg(DOCBOOK_XML_CURRDTD); } #endif xsltStylesheetPtr style_sheet = xsltParseStylesheetFile((const xmlChar *)QFile::encodeName(tss).constData()); if (!style_sheet) { return parsed; } if (style_sheet->indent == 1) { xmlIndentTreeOutput = 1; } else { xmlIndentTreeOutput = 0; } INFO(i18n("Parsing document")); xmlParserCtxtPtr pctxt; pctxt = xmlNewParserCtxt(); if ( pctxt == NULL ) { return parsed; } xmlDocPtr doc = xmlCtxtReadFile(pctxt, QFile::encodeName(pat).constData(), NULL, XML_PARSE_NOENT|XML_PARSE_DTDLOAD|XML_PARSE_NONET); /* Clean the context pointer, now useless */ const bool context_valid = (pctxt->valid == 0); xmlFreeParserCtxt(pctxt); /* Check both the returned doc (for parsing errors) and the context (for validation errors) */ if (doc == NULL) { return parsed; } else { if (context_valid) { xmlFreeDoc(doc); return parsed; } } INFO(i18n("Applying stylesheet")); QVector<const char *> p = params; p.append(NULL); xmlDocPtr res = xsltApplyStylesheet(style_sheet, doc, const_cast<const char **>(&p[0])); xmlFreeDoc(doc); if (res != NULL) { xmlOutputBufferPtr outp = xmlOutputBufferCreateIO(writeToQString, 0, &parsed, 0); outp->written = 0; INFO(i18n("Writing document")); xsltSaveResultTo(outp, res, style_sheet); xmlOutputBufferClose(outp); xmlFreeDoc(res); } xsltFreeStylesheet(style_sheet); if (parsed.isEmpty()) { parsed = QLatin1Char(' '); // avoid error message } return parsed; }
void NotificationView::removedFromQml(int index) { INFO("Someone clicked remove from qml index = " << index ); INotificationView::requireRemove(index); }
volume* Volume::extractFinalVolume(volume* iOriginaVol, const subVolDim* iSubVolDim) { INFO("Extracting SUB-VOLUME to be processed in a SINGLE thread"); INFO("Allocating CUBE array for the original volume : " + STRG( "[" ) + ITS( iOriginaVol->sizeX ) + STRG( "]" ) + " x " + STRG( "[" ) + ITS( iOriginaVol->sizeY ) + STRG( "]" ) + " x " + STRG( "[" ) + ITS( iOriginaVol->sizeZ ) + STRG( "]" )); /* @ Allocating cube array for the original volume */ char*** originalCubeVol = Volume::allocCubeVolume_char (iOriginaVol->sizeX, iOriginaVol->sizeY, iOriginaVol->sizeZ); INFO("Packing the FLAT array in the CUBE "); /* @ Packing the original flat volume in the cube */ Volume::packCubeVolume(originalCubeVol, iOriginaVol); /* @ Allocating the final volume */ volume* iFinalSubVolume = (volume*) malloc (sizeof(volume)); iFinalSubVolume->sizeX = iSubVolDim->max_X - iSubVolDim->min_X; iFinalSubVolume->sizeY = iSubVolDim->max_Y - iSubVolDim->min_Y; iFinalSubVolume->sizeZ = iSubVolDim->max_Z - iSubVolDim->min_Z; if (iFinalSubVolume->sizeX == iFinalSubVolume->sizeY && iFinalSubVolume->sizeX == iFinalSubVolume->sizeZ) { INFO("Final SUB-VOLUME has unified dimensions " + ITS(iFinalSubVolume->sizeX)); iFinalSubVolume->sizeUni = iFinalSubVolume->sizeZ; } else { INFO("Final SUB-VOLUME DOESN'T have unified dimensions " + ITS(iFinalSubVolume->sizeX)); EXIT(0); } iFinalSubVolume->ptrVol_char = (char*) malloc (sizeof(char) * iFinalSubVolume->sizeX * iFinalSubVolume->sizeY * iFinalSubVolume->sizeZ); INFO("Allocating CUBE array for the final SUB-VOLUME: " + STRG( "[" ) + ITS( iFinalSubVolume->sizeX ) + STRG( "]" ) + " x " + STRG( "[" ) + ITS( iFinalSubVolume->sizeY ) + STRG( "]" ) + " x " + STRG( "[" ) + ITS( iFinalSubVolume->sizeZ ) + STRG( "]" )); /* @ Allocating the final cube volume "SUB-VOLUME" */ char*** finalCubeVol = Volume::allocCubeVolume_char (iFinalSubVolume->sizeX, iFinalSubVolume->sizeY, iFinalSubVolume->sizeZ); INFO("Extractng the SUB-VOLUME"); /* @ Extractig the SUB-VOLUME */ Volume::extractSubVolume(originalCubeVol, finalCubeVol, iSubVolDim); for (int y = 0; y < iFinalSubVolume->sizeY; y++) { for (int x = 0; x < iFinalSubVolume->sizeY; x++) free(originalCubeVol[y][x]); free(originalCubeVol[y]); } free(originalCubeVol); originalCubeVol = NULL; /* @ Dellocating the original cube volume */ // FREE_MEM_3D_CHAR(originalCubeVol, iOriginaVol->sizeX, iOriginaVol->sizeY, iOriginaVol->sizeZ); /* @ Packing the final cube volume in the flat array */ Volume::packFlatVolume(iFinalSubVolume, finalCubeVol); for (int y = 0; y < iFinalSubVolume->sizeY; y++) { for (int x = 0; x < iFinalSubVolume->sizeY; x++) free(finalCubeVol[y][x]); free(finalCubeVol[y]); } free(finalCubeVol); finalCubeVol = NULL; //FREE_MEM_3D_CHAR(finalCubeVol, iFinalSubVolume->sizeX, iFinalSubVolume->sizeY, iFinalSubVolume->sizeZ); INFO("Final volume extraction DONE"); return iFinalSubVolume; }
bool DSMFactory::loadConfig(const string& conf_file_name, const string& conf_name, bool live_reload, DSMStateDiagramCollection* m_diags) { string script_name = conf_name.substr(0, conf_name.length()-5); // - .conf DBG("loading %s from %s ...\n", script_name.c_str(), conf_file_name.c_str()); AmConfigReader cfg; if(cfg.loadFile(conf_file_name)) return false; DSMScriptConfig script_config; script_config.RunInviteEvent = cfg.getParameter("run_invite_event")=="yes"; script_config.SetParamVariables = cfg.getParameter("set_param_variables")=="yes"; script_config.config_vars.insert(cfg.begin(), cfg.end()); if (live_reload) { INFO("live DSM config reload does NOT reload prompts and prompt sets!\n"); INFO("(see http://tracker.iptel.org/browse/SEMS-68)\n"); } else { if (!loadPrompts(cfg)) return false; if (!loadPromptSets(cfg)) return false; } DSMStateDiagramCollection* used_diags; if (m_diags != NULL) used_diags = m_diags; // got this from caller (main diags) else { // create a new set of diags used_diags = script_config.diags = new DSMStateDiagramCollection(); } if (!loadDiags(cfg, used_diags)) return false; vector<string> registered_apps; if (!registerApps(cfg, used_diags, registered_apps)) return false; ScriptConfigs_mut.lock(); try { Name2ScriptConfig[script_name] = script_config; // set ScriptConfig to this for all registered apps' names for (vector<string>::iterator reg_app_it= registered_apps.begin(); reg_app_it != registered_apps.end(); reg_app_it++) { string& app_name = *reg_app_it; // dispose of the old one, if it exists map<string, DSMScriptConfig>::iterator it=ScriptConfigs.find(app_name); if (it != ScriptConfigs.end()) { // may be in use by active call - don't delete but save to // old_diags for garbage collection (destructor) if (it->second.diags != NULL) old_diags.insert(it->second.diags); } // overwrite with new config ScriptConfigs[app_name] = script_config; } } catch(...) { ScriptConfigs_mut.unlock(); throw; } ScriptConfigs_mut.unlock(); bool res = true; vector<string> system_dsms = explode(cfg.getParameter("run_system_dsms"), ","); for (vector<string>::iterator it=system_dsms.begin(); it != system_dsms.end(); it++) { string status; if (createSystemDSM(script_name, *it, live_reload, status)) { } else { ERROR("creating system DSM '%s': '%s'\n", it->c_str(), status.c_str()); res = false; } } return res; }