BOOST_FIXTURE_TEST_CASE(ChangePredicate, UdpFactoryMcastFixture) { #ifdef __linux__ // need superuser privileges to create multicast faces on Linux SKIP_IF_NOT_SUPERUSER(); #endif // __linux__ SKIP_IF_UDP_MCAST_NETIF_COUNT_LT(2); std::string CONFIG1 = R"CONFIG( face_system { udp { whitelist { ifname %ifname } } } )CONFIG"; std::string CONFIG2 = CONFIG1; boost::replace_first(CONFIG1, "%ifname", netifs.front()->getName()); boost::replace_first(CONFIG2, "%ifname", netifs.back()->getName()); parseConfig(CONFIG1, false); auto udpMcastFaces = this->listUdp4McastFaces(); auto udpMcastFacesV6 = this->listUdp6McastFaces(); udpMcastFaces.insert(udpMcastFaces.end(), udpMcastFacesV6.begin(), udpMcastFacesV6.end()); BOOST_CHECK_GE(udpMcastFaces.size(), 1); BOOST_CHECK(std::all_of(udpMcastFaces.begin(), udpMcastFaces.end(), [this] (const Face* face) { return isFaceOnNetif(*face, *netifs.front()); })); parseConfig(CONFIG2, false); g_io.poll(); udpMcastFaces = this->listUdp4McastFaces(); udpMcastFacesV6 = this->listUdp6McastFaces(); udpMcastFaces.insert(udpMcastFaces.end(), udpMcastFacesV6.begin(), udpMcastFacesV6.end()); BOOST_CHECK_GE(udpMcastFaces.size(), 1); BOOST_CHECK(std::all_of(udpMcastFaces.begin(), udpMcastFaces.end(), [this] (const Face* face) { return isFaceOnNetif(*face, *netifs.back()); })); } BOOST_AUTO_TEST_CASE(Omitted) { const std::string CONFIG = R"CONFIG( face_system { } )CONFIG"; parseConfig(CONFIG, true); parseConfig(CONFIG, false); BOOST_CHECK_EQUAL(factory.getChannels().size(), 0); BOOST_CHECK_EQUAL(this->listFacesByScheme("udp4", ndn::nfd::LINK_TYPE_MULTI_ACCESS).size(), 0); BOOST_CHECK_EQUAL(this->listFacesByScheme("udp6", ndn::nfd::LINK_TYPE_MULTI_ACCESS).size(), 0); }
int Config::readConfig(std::string filename) { std::ifstream fin; std::string input; fin.open(filename.c_str()); if (!fin) { std::cerr << "Error: Could not open config file \'" << filename << "\'" << std::endl; return 1; } int counter = 0; char** charArr = new char*[100]; char string[200]; while (fin >> string && counter < 100) { charArr[counter] = new char[200]; strncpy(charArr[counter], string, 200); counter++; } parseConfig(0,counter, charArr); for (int i = 0; i < counter; i++) { delete[] (charArr[i]); } delete[] charArr; fin.close(); return 0; }
int main( int argc, char** argv ) { int status = EXIT_SUCCESS; if(argc >= 2) { if( parseConfig(argv[1]) ) { getEntities(_entityPath); testDir(_testPath); } else status = EXIT_FAILURE; } else { status = EXIT_FAILURE; std::cout << "Problem lauching program." << std::endl << "USAGE: contextIdentifier <path to config file>" << std::endl; } return status; /**setMovie( "The Grey", "./data/movies/grey.jpg" ); setMovie( "The Silence of the Lambs", "./data/movies/lambs.jpg" ); setMovie( "The Dark Knight", "./data/movies/batman.jpg" ); testDir( "./data/movies/tests" ); setMovie( "Bom Jesus", "./data/monuments/bom_jesus.jpg" ); setMovie( "Sameiro", "./data/monuments/sameiro.jpg" ); testDir( "./data/monuments/tests" );*/ }
void Config::parseOpenSMTCMDLine( int argc , char * argv[ ] ) { char config_name[ 64 ]; for ( int i = 1 ; i < argc - 1 ; i ++ ) { const char * buf = argv[ i ]; // Parsing of configuration options if ( sscanf( buf, "--config=%s", config_name ) == 1 ) { parseConfig( config_name ); break; } else if ( strcmp( buf, "--help" ) == 0 || strcmp( buf, "-h" ) == 0 ) { printHelp( ); exit( 1 ); } else { printHelp( ); opensmt_error2( "unrecognized option", buf ); } } if ( dump_log ) log_out.open( ".opensmt_log.smt2" ); }
CmdOptions * Config::createConfig (int argc, const char *argv[]) { // Allocate the options CmdOptions *opts = new CmdOptions; if (!opts) { return NULL; } // Parse any command line options if (!opts->parseArgs (argc, argv)) { goto error; } // If there is no init configuration file, we are done char *ini_config_file; if (!(ini_config_file = opts->getIniConfigFile())) { return opts; } // Parse the init file if (!parseConfig(ini_config_file, opts)) { std::cerr << "INI config file parse failed" << std::endl; goto error; } return opts; error: delete opts; return NULL; }
bool OidentdConfigGenerator::init() { _configDir = QDir::homePath(); _configFileName = ".oidentd.conf"; if (Quassel::isOptionSet("oidentd-conffile")) _configPath = Quassel::optionValue("oidentd-conffile"); else _configPath = _configDir.absoluteFilePath(_configFileName); _configTag = " stanza created by Quassel"; _configFile = new QFile(_configPath); // Rx has to match Template in order for cleanup to work. // Template should be enhanced with the "from" parameter as soon as Quassel gains // the ability to bind to an IP on client sockets. _quasselStanzaTemplate = QString("lport %1 { reply \"%2\" } #%3\n"); _quasselStanzaRx = QRegExp(QString("^lport .* \\{ .* \\} #%1\\r?\\n").arg(_configTag)); // initially remove all Quassel stanzas that might be present if (parseConfig(false) && writeConfig()) _initialized = true; return _initialized; }
void WINAPI ServiceMain( DWORD argc, LPSTR *argv ) { std::memset( &SPEPService::serviceStatus, 0, sizeof(SPEPService::serviceStatus) ); SPEPService::serviceStatus.dwServiceType = SERVICE_WIN32; SPEPService::serviceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP; SPEPService::updateStatus( SERVICE_START_PENDING ); std::vector<saml2::Handler*> handlers; std::auto_ptr<spep::daemon::StreamLogHandler> logHandler; std::auto_ptr<std::ostream> stream; std::string logFilename; boost::program_options::variables_map configFileVariableMap; bool readConfig = false; // Open the registry to get the filename RegistryKey rKeySoftware( HKEY_LOCAL_MACHINE, REGISTRY_KEY_SOFTWARE, KEY_ENUMERATE_SUB_KEYS ); if( rKeySoftware.valid() ) { RegistryKey rKeyESOEProject( rKeySoftware, REGISTRY_KEY_ESOEPROJECT, KEY_ENUMERATE_SUB_KEYS ); if( rKeyESOEProject.valid() ) { RegistryKey rKeySPEP( rKeyESOEProject, REGISTRY_KEY_SPEP, KEY_READ ); if( rKeySPEP.valid() ) { std::string configFilename( rKeySPEP.queryValueString( "ConfigFile" ) ); logFilename = ( rKeySPEP.queryValueString( "LogFile" ) ); if( logFilename.length() != 0 ) { stream.reset( new std::ofstream( logFilename.c_str() ) ); logHandler.reset( new spep::daemon::StreamLogHandler( *stream, spep::DEBUG ) ); handlers.push_back( logHandler.get() ); } // Read the file std::ifstream configFileInput( configFilename.c_str() ); if( configFileInput.good() ) { parseConfig( configFileVariableMap, configFileInput, handlers ); readConfig = true; } else { directLog( handlers, "The config file specified in the registry key doesn't exist." ); return; } } else { directLog( handlers, "Couldn't open HKEY_LOCAL_MACHINE\Software\ESOE Project\SPEP" ); return; } }
/** * Initializes a property set with the contents of a property file. * * @param props The property set to initialize * @param name The name of the property file to load. It is relative * to the <tt>configRoot</tt> path. * @param configRoot The fully qualified pathname to the root * configuration directory. * * @return <tt>0</tt> for success, otherwise <tt>-1</tt> */ static int initProps(Property** props, const pcsl_string * name, const pcsl_string * configRoot) { pcsl_string pathname; int fd = -1 ; char * errStr; /* Property file can be relative or at midp_home variable */ pcsl_string_cat(configRoot, name, &pathname); fd = storage_open(&errStr, &pathname, OPEN_READ); pcsl_string_free(&pathname); if (errStr != NULL) { REPORT_WARN2(LC_CORE, "Warning: could not open config file(%s): %s\n", pathname, errStr); storageFreeError(errStr); return 0; } /* Read through the file one line at a time */ if (parseConfig(fd, props) != 0) { return -1; } /* Close the storage handle */ storageClose(&errStr, fd); return 0; }
bool sctpServer::start(const QString &config) { parseConfig(config); if (!listen(QHostAddress::Any, mPort)) { qCritical() << QObject::tr("Unable to start the server: %1").arg(errorString()); return false; } QString ipAddress; QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses(); // use the first non-localhost IPv4 address for (int i = 0; i < ipAddressesList.size(); ++i) { if (ipAddressesList.at(i) != QHostAddress::LocalHost && ipAddressesList.at(i).toIPv4Address()) { ipAddress = ipAddressesList.at(i).toString(); break; } } // if we did not find one, use IPv4 localhost if (ipAddress.isEmpty()) ipAddress = QHostAddress(QHostAddress::LocalHost).toString(); QString message = QObject::tr("The server is running on\nIP: %1\tport: %2\n") .arg(ipAddress).arg(serverPort()); qDebug() << message.toUtf8().constData(); // initialize sc-memory qDebug() << "Initialize sc-memory\n"; sc_memory_params params; sc_memory_params_clear(¶ms); std::string config_path = config.toStdString(); std::string repo_path = mRepoPath.toStdString(); std::string ext_path = mExtPath.toStdString(); params.clear = SC_FALSE; params.config_file = config_path.c_str(); params.repo_path = repo_path.c_str(); params.ext_path = ext_path.c_str(); mContext = sc_memory_initialize(¶ms); if (mContext == 0) return false; mEventManager = new sctpEventManager(); mEventManager->initialize(); if (mStatUpdatePeriod > 0) { mStatistic = new sctpStatistic(this); mStatistic->initialize(mStatPath, mStatUpdatePeriod, mContext); } QTimer::singleShot(mSavePeriod * 1000, this, SLOT(onSave())); return true; }
int Config::parseCommandLine(int argc, char **argv) { if (argc < 2) { std::cerr << "Not enough command line provided." << std::endl; return 1; } else { return parseConfig(1,argc, argv); } }
void SceneParser::parse(void) { parseConfig(); acceptToken(Scanner::Separator); advance(); parseObjects(); parseToken(Scanner::StreamDone); }
//------------------------------------------------------------------------------ // This procedure takes a filename as argument (which has already been verified // as readable) process it as if the contents were part of the original config file // In other words, this code supports 'include' syntax for the config files void process_include( char *incfile ) { if(verbose) { fprintf(stderr, "getlts::process_include [%s]\n",incfile); } // attempt to parse the new config file parseConfig(incfile); }
BLTreeEngine::BLTreeEngine( const std::string& path ) : _path( path ) { BLTConfig conf; parseConfig( _path, &conf ); BufMgr* mgr = BufMgr::create( conf._metaName, conf._openMode, conf._pageBits, conf._poolSize, conf._segBits, conf._hashSize ); _blt = BLTree::create( mgr ); }
int odbcConf::configRead() { int rec = 0; FILE* file = fopen(m_onfig_file,"r+"); if (!file) { rec = NOT_FOUND_CONFIGFILE; return rec; } std::ifstream fs(this->m_onfig_file); //释放配置文件结构 deleteCofigInfo(); //是否到达文件尾部 std::string str_tmp; while (!fs.eof()) { std::getline(fs,str_tmp); if (str_tmp.find("=",0)==std::string::npos) { continue; } char* token = "="; const char* source = str_tmp.data(); std::vector<std::string> v = splitString(source,token); if (m_config_head) { configNode* _node = new configNode(); _node->key = v[0]; _node->value = v[1]; _node->next = m_config_head; m_config_head = _node; }else { m_config_head = new configNode(); m_config_head->key = v[0]; m_config_head->value = v[1]; m_config_head->next = NULL; } } fclose(file); fs.close(); rec = parseConfig(); if (rec==0) { m_conn_str = generateConnStr(); } return rec; }
void ThreadController::startScheduler(QSchedulerConfig *config) { if (scheduler_running_) return; ui_scheduler_ = new UIScheduler; scheduler_thread_ = new QThread; ConnectSignals(); scheduler_thread_->start(); ui_scheduler_->moveToThread(scheduler_thread_); emit schedulerProcess(parseConfig(config)); }
void MiniBeeV2::readConfigMsg(char *msg){ config = (char*)malloc(sizeof(char) * CONFIG_BYTES); for(i = 0;i < CONFIG_BYTES;i++){ config[i] = msg[i+1]; } parseConfig(); free(config); if ( hasInput ){ status = SENSING; } else if ( hasOutput ){ status = ACTING; } }
DatabaseSink::DatabaseSink(AbstractRoutingEngine *engine, map<std::string, std::string> config) :AbstractSource(engine,config),thread(NULL),shared(NULL),playback(false),playbackShared(NULL), playbackMultiplier(1) { databaseName = "storage"; tablename = "data"; tablecreate = "CREATE TABLE IF NOT EXISTS data (key TEXT, value BLOB, source TEXT, time REAL, sequence REAL)"; if(config.find("databaseFile") != config.end()) { setDatabaseFileName(config["databaseFile"]); } if(config.find("bufferLength") != config.end()) { bufferLength = atoi(config["bufferLength"].c_str()); } if(config.find("properties") != config.end()) { parseConfig(); } for(auto itr=propertiesToSubscribeTo.begin();itr!=propertiesToSubscribeTo.end();itr++) { engine->subscribeToProperty(*itr,this); } mSupported.push_back(DatabaseFile); mSupported.push_back(DatabaseLogging); mSupported.push_back(DatabasePlayback); routingEngine->setSupported(supported(), this); if(config.find("startOnLoad")!= config.end()) { setLogging(true); } if(config.find("playbackMultiplier")!= config.end()) { playbackMultiplier = boost::lexical_cast<uint>(config["playbackMultiplier"]); } if(config.find("playbackOnLoad")!= config.end()) { setPlayback(true); } }
int main( void ) { Window win; win.open(); parseConfig(win); while (42) { win.refresh(); win.flush(); if (wgetch(win.getWindow()) == 'q') break; } win.close(); return (0); (void)win; }
/* main method {{{ */ int main(int argc, char *argv[]) { ConfigMap config; if(!parseOptions(argc,argv,config)) { //Parse cmd line options cerr << "==> Try '" << argv[0] << " --usage'" << endl; return -1; } if(config.find("usage")!=config.end()||config.find("help")!=config.end()) { usage(argv[0]); return -1; } if(!parseConfig(config)) { cerr << "==> Try 'man " << argv[0] << "'" << endl; return -1; } return mainFunction(config); }
int main(int argc, char *argv[]) { int rc; fd_set readmask; /* pending */ currentAgent.sin_addr.s_addr = 0; parseConfig(argc, argv); if(signal(SIGALRM, sig_alarm) == SIG_ERR){ printf( "[X] signal() error.\n"); exit(1); } ualarm(1, 0); /* Initialize broadcast socket. */ initSockets(); /* printf( "Sockets have been created successfully.\n"); */ while(1){ FD_ZERO(&readmask); FD_SET(listenSocket, &readmask); /* #define DEBUG_MND_SELECT */ #ifdef DEBUG_MND_SELECT printf( "mnd: Start to select().\n"); #endif rc = select(replySocket+1, /*pending: last socket!?*/ (fd_set *)&readmask, NULL, NULL, NULL); #ifdef DEBUG_MND_SELECT printf( "mnd: End of select(), rc=%d, errno:%d\n", rc, errno); #endif if(rc < 0){ if(errno ==EINTR){ /* printf( "errno == EINTR.\n"); */ continue; } printf( "[X] rc < 0. \n"); exit(1); } if(FD_ISSET(listenSocket, &readmask)){ handleListenSocket(listenSocket); } } return 0; }
void MainWindow::loadWorkspace(std::string workspaceFile) { QStringList fileNames; //stores the entire path of the file that it attempts to open if (workspaceFile.empty()) { QStringList filters; //setting file filters filters << "ReViz configuration files (*.revizconfig)" << "Any files (*)"; //initializing the File dialog box //the static QFileDialog does not seem to be working correctly in Ubuntu 12.04 with unity. //as per the documentation it may work correctly with gnome //the method used below should work correctly on all desktops and is supposedly more powerful QFileDialog dialog(this); dialog.setNameFilters(filters); dialog.setAcceptMode(QFileDialog::AcceptOpen); dialog.setFileMode(QFileDialog::ExistingFile); if (dialog.exec()) fileNames = dialog.selectedFiles(); } else { fileNames.append(QString::fromStdString(workspaceFile)); } if (!fileNames.isEmpty()){ std::cerr << "Attempting to load the following configuration file: "<< fileNames.front().toStdString() << std::endl; try { QFile file(fileNames.front()); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { std::cerr << "Unable to open file." << std::endl; return; } QDomDocument config; QString errorMsg; int errorLine, errorColumn; if(config.setContent(&file, &errorMsg, &errorLine, &errorColumn)) { parseConfig(config); *configFilePath = fileNames.front(); } } catch(const std::exception& e){ std::cerr << e.what() << std::endl; } } }
int main() { addLog("==========================================================="); addLog("NWChecker started"); string curdir=getCurrentDir(); loadResults(); if (parseConfig()) return 1; checkAll(); SetCurrentDirectory(curdir.c_str()); generateHTML(); saveResults(); if(silentMode) { int i; cin>>i; } return 0; }
void Config::parse(int argc, char **argv) { // parse command line try { po::store(po::parse_command_line(argc, argv, optdesc_), opts_); po::notify(opts_); } catch (std::exception &e) { error_ = e.what(); return; } // fill in internal variables with values received from command line handleCmdLine(); // parse configuration file only if command line is correct if (ok_) { parseConfig(); } }
BOOST_FIXTURE_TEST_CASE(Whitelist, UdpFactoryMcastFixture) { #ifdef __linux__ // need superuser privileges to create multicast faces on Linux SKIP_IF_NOT_SUPERUSER(); #endif // __linux__ SKIP_IF_UDP_MCAST_NETIF_COUNT_LT(1); std::string CONFIG = R"CONFIG( face_system { udp { whitelist { ifname %ifname } } } )CONFIG"; boost::replace_first(CONFIG, "%ifname", netifs.front()->getName()); parseConfig(CONFIG, false); auto udpMcastFaces = this->listUdp4McastFaces(); BOOST_CHECK_LE(udpMcastFaces.size(), 1); auto udpMcastFacesV6 = this->listUdp6McastFaces(); BOOST_CHECK_LE(udpMcastFacesV6.size(), 1); udpMcastFaces.insert(udpMcastFaces.end(), udpMcastFacesV6.begin(), udpMcastFacesV6.end()); BOOST_CHECK_GE(udpMcastFaces.size(), 1); BOOST_CHECK(std::all_of(udpMcastFaces.begin(), udpMcastFaces.end(), [this] (const Face* face) { return isFaceOnNetif(*face, *netifs.front()); })); } BOOST_FIXTURE_TEST_CASE(Blacklist, UdpFactoryMcastFixture) { #ifdef __linux__ // need superuser privileges to create multicast faces on Linux SKIP_IF_NOT_SUPERUSER(); #endif // __linux__ SKIP_IF_UDP_MCAST_NETIF_COUNT_LT(1); std::string CONFIG = R"CONFIG( face_system { udp { blacklist { ifname %ifname } } } )CONFIG"; boost::replace_first(CONFIG, "%ifname", netifs.front()->getName()); parseConfig(CONFIG, false); auto udpMcastFaces = this->listUdp4McastFaces(); if (!netifsV4.empty()) BOOST_CHECK_GE(udpMcastFaces.size(), netifsV4.size() - 1); auto udpMcastFacesV6 = this->listUdp6McastFaces(); if (!netifsV6.empty()) BOOST_CHECK_GE(udpMcastFacesV6.size(), netifsV6.size() - 1); udpMcastFaces.insert(udpMcastFaces.end(), udpMcastFacesV6.begin(), udpMcastFacesV6.end()); BOOST_CHECK_LT(udpMcastFaces.size(), netifsV4.size() + netifsV6.size()); BOOST_CHECK(std::none_of(udpMcastFaces.begin(), udpMcastFaces.end(), [this] (const Face* face) { return isFaceOnNetif(*face, *netifs.front()); })); }
int main(int argc, char *argv[]) { int c; char *configFile = NULL; char *host = NULL; unsigned short port = 0; char *mount = NULL; shout_t *shout; extern char *optarg; extern int optind; #ifdef HAVE_SIGNALS struct sigaction act; unsigned int i; #endif #ifdef XALLOC_DEBUG xalloc_initialize_debug(2, NULL); #else xalloc_initialize(); #endif /* XALLOC_DEBUG */ playlist_init(); shout_init(); __progname = getProgname(argv[0]); pezConfig = getEZConfig(); mFlag = 0; nFlag = 0; qFlag = 0; vFlag = 0; while ((c = local_getopt(argc, argv, "c:hmnqsVv")) != -1) { switch (c) { case 'c': if (configFile != NULL) { printf("Error: multiple -c arguments given\n"); usage(); return (ez_shutdown(2)); } configFile = xstrdup(optarg); break; case 'h': usage(); usageHelp(); return (ez_shutdown(0)); case 'm': mFlag = 1; break; case 'n': nFlag = 1; break; case 'q': qFlag = 1; break; case 's': sFlag = 1; break; case 'V': printf("%s\n", PACKAGE_STRING); return (ez_shutdown(0)); case 'v': vFlag++; break; case '?': usage(); return (ez_shutdown(2)); default: break; } } argc -= optind; argv += optind; if (sFlag) { playlist_t *pl; const char *entry; switch (argc) { case 0: pl = playlist_read(NULL); if (pl == NULL) return (ez_shutdown(1)); break; case 1: pl = playlist_read(argv[0]); if (pl == NULL) return (ez_shutdown(1)); break; default: printf("Error: Too many arguments.\n"); return (ez_shutdown(2)); } playlist_shuffle(pl); while ((entry = playlist_get_next(pl)) != NULL) printf("%s\n", entry); playlist_free(&pl); return (ez_shutdown(0)); } if (configFile == NULL) { printf("You must supply a config file with the -c argument.\n"); usage(); return (ez_shutdown(2)); } else { /* * Attempt to open configFile here for a more meaningful error * message. Where possible, do it with stat() and check for * safe config file permissions. */ #ifdef HAVE_STAT struct stat st; if (stat(configFile, &st) == -1) { printf("%s: %s\n", configFile, strerror(errno)); usage(); return (ez_shutdown(2)); } if (vFlag && (st.st_mode & (S_IRGRP | S_IROTH))) printf("%s: Warning: %s is group and/or world readable\n", __progname, configFile); if (st.st_mode & (S_IWGRP | S_IWOTH)) { printf("%s: Error: %s is group and/or world writeable\n", __progname, configFile); return (ez_shutdown(2)); } #else FILE *tmp; if ((tmp = fopen(configFile, "r")) == NULL) { printf("%s: %s\n", configFile, strerror(errno)); usage(); return (ez_shutdown(2)); } fclose(tmp); #endif /* HAVE_STAT */ } if (!parseConfig(configFile)) return (ez_shutdown(2)); if (pezConfig->URL == NULL) { printf("%s: Error: Missing <url>\n", configFile); return (ez_shutdown(2)); } if (!urlParse(pezConfig->URL, &host, &port, &mount)) { printf("Must be of the form ``http://server:port/mountpoint''\n"); return (ez_shutdown(2)); } if (strlen(host) == 0) { printf("%s: Error: Invalid <url>: Missing server:\n", configFile); printf("Must be of the form ``http://server:port/mountpoint''\n"); return (ez_shutdown(2)); } if (strlen(mount) == 0) { printf("%s: Error: Invalid <url>: Missing mountpoint:\n", configFile); printf("Must be of the form ``http://server:port/mountpoint''\n"); return (ez_shutdown(2)); } if (pezConfig->password == NULL) { printf("%s: Error: Missing <sourcepassword>\n", configFile); return (ez_shutdown(2)); } if (pezConfig->fileName == NULL) { printf("%s: Error: Missing <filename>\n", configFile); return (ez_shutdown(2)); } if (pezConfig->format == NULL) { printf("%s: Warning: Missing <format>:\n", configFile); printf("Specify a stream format of either MP3, VORBIS or THEORA\n"); } xfree(configFile); if ((shout = stream_setup(host, port, mount)) == NULL) return (ez_shutdown(1)); if (pezConfig->metadataProgram != NULL) metadataFromProgram = 1; else metadataFromProgram = 0; #ifdef HAVE_SIGNALS memset(&act, 0, sizeof(act)); act.sa_handler = sig_handler; # ifdef SA_RESTART act.sa_flags = SA_RESTART; # endif for (i = 0; i < sizeof(ezstream_signals) / sizeof(int); i++) { if (sigaction(ezstream_signals[i], &act, NULL) == -1) { printf("%s: sigaction(): %s\n", __progname, strerror(errno)); return (ez_shutdown(1)); } } /* * Ignore SIGPIPE, which has been seen to give a long-running ezstream * process trouble. EOF and/or EPIPE are also easier to handle. */ act.sa_handler = SIG_IGN; if (sigaction(SIGPIPE, &act, NULL) == -1) { printf("%s: sigaction(): %s\n", __progname, strerror(errno)); return (ez_shutdown(1)); } #endif /* HAVE_SIGNALS */ if (shout_open(shout) == SHOUTERR_SUCCESS) { int ret; printf("%s: Connected to http://%s:%hu%s\n", __progname, host, port, mount); if (pezConfig->fileNameIsProgram || strrcasecmp(pezConfig->fileName, ".m3u") == 0 || strrcasecmp(pezConfig->fileName, ".txt") == 0) playlistMode = 1; else playlistMode = 0; if (vFlag && pezConfig->fileNameIsProgram) printf("%s: Using program '%s' to get filenames for streaming\n", __progname, pezConfig->fileName); do { if (playlistMode) { ret = streamPlaylist(shout, pezConfig->fileName); } else { ret = streamFile(shout, pezConfig->fileName); } if (quit) break; if (pezConfig->streamOnce) break; } while (ret); shout_close(shout); } else printf("%s: Connection to http://%s:%hu%s failed: %s\n", __progname, host, port, mount, shout_get_error(shout)); if (quit) printf("\r%s: SIGINT or SIGTERM received\n", __progname); if (vFlag) printf("%s: Exiting ...\n", __progname); xfree(host); xfree(mount); playlist_free(&playlist); return (ez_shutdown(0)); }
void Expert::loadConfig(const QString &fileName) { //printf("Expert::loadConfig(%s)\n",qPrintable(fileName)); parseConfig(fileName,m_options); }
void MiniBeeV2::readConfig(void) { config = (char*)malloc(sizeof(char) * CONFIG_BYTES); for(i = 0;i < CONFIG_BYTES;i++) config[i] = eeprom_read_byte((uint8_t *) i); parseConfig(); free(config); }
void SMTConfig::parseCMDLine( int argc , char * argv[ ] ) { char config_name[ 64 ]; for ( int i = 1 ; i < argc - 1 ; i ++ ) { const char * buf = argv[ i ]; // Parsing of configuration options if ( sscanf( buf, "--config=%s", config_name ) == 1 ) { parseConfig( config_name ); continue; } if ( sscanf( buf, "--precision=%lf", &nra_precision ) == 1) { if(nra_precision <= 0.0) { printHelp( ); exit( 1 ); } continue; } if ( sscanf( buf, "--ode-step=%lf", &nra_ODE_step ) == 1) { if(nra_ODE_step <= 0.0) { printHelp( ); exit( 1 ); } continue; } if ( sscanf( buf, "--ode-order=%d", &nra_ODE_taylor_order ) == 1) { continue; } if ( sscanf( buf, "--ode-grid=%d", &nra_ODE_grid_size ) == 1) { continue; } if ( strcmp( buf, "--ode-parallel" ) == 0 ) { nra_parallel_ODE = true; continue; } if ( strcmp( buf, "--help" ) == 0 ) { printHelp( ); exit( 1 ); } if ( strcmp( buf, "--proof" ) == 0 ) { nra_proof = true; /* Open file stream */ nra_proof_out_name = string(argv[ argc - 1 ]) + ".proof"; nra_proof_out.open (nra_proof_out_name.c_str(), std::ofstream::out | std::ofstream::trunc); if(nra_proof_out.fail()) { cout << "Cannot create a file: " << nra_proof_out_name << endl; exit( 1 ); } continue; } if ( strcmp( buf, "--visualize" ) == 0 ) { nra_json = true; string filename = string(argv[ argc - 1 ]) + ".json"; /* Open file stream */ nra_json_out.open (filename.c_str(), std::ofstream::out | std::ofstream::trunc ); if(nra_json_out.fail()) { cout << "Cannot create a file: " << filename << endl; exit( 1 ); } continue; } if ( strcmp( buf, "--verbose" ) == 0) { set_log_level(LogLevel::DEBUG); nra_verbose = true; continue; } else { printHelp( ); opensmt_error2( "unrecognized option", buf ); } } }
linear_population_growth_generator::linear_population_growth_generator( boost::property_tree::ptree & p ) : m_A(1.0) , m_B(0.0) { parseConfig( p ); }
int main(){ Uavcam *camera; bool camera_ok, frame_ok; int n_saved; std::stringstream filename; std::stringstream directory; std::vector<int> jpg_params; cv::Mat frame, preview; parseConfig(); jpg_params.push_back(CV_IMWRITE_JPEG_QUALITY); jpg_params.push_back(90); //Set Signals std::signal(SIGINT,exit_signal); //Set up Ctrl+C signal //Construct Cameras if (cameratype == 1){ #ifdef USE_ARAVIS camera = new AravisCam(); std::cout<<"Using Aravis camera"<<std::endl; #else camera = new WebCam(); #endif } if(view) cv::namedWindow("Camera Viewer", cv::WINDOW_AUTOSIZE); n_saved = checkLog(); //Check the log and open it openLogtoWrite(n_saved); ublox = new Gps(); //Initialize the GPS std::thread gps_thread(gpsUpdate); camera_ok = camera->initializeCam(); //Initialize the camera if (camera_ok) { std::cout << "Start camera acquisition in " << start_delay << " seconds" << std::endl; std::this_thread::sleep_for(std::chrono::seconds(start_delay)); while(!finish){ //--Main Acquisition Loop filename.str(""); directory.str(""); //Update filenames filename<<"im"<<std::setfill('0')<<std::setw(4)<<++n_saved<<".jpg"; directory<<FOLDER<<filename.str(); camera->trigger(); //Send camera trigger if (usegps){ if(ublox->data_is_good) std::cout<<"GPS up to date"<<std::endl; else std::cout<<"No GPS available" <<std::endl; } mtx.lock(); writeImageInfo(ublox->current_loc, filename.str()); //Record GPS mtx.unlock(); frame_ok = camera->getImage(frame); //Acquire the image if(frame_ok){ //Acquired Image cv::resize(frame,preview,cv::Size(),sizefac,sizefac,cv::INTER_NEAREST); if(saveimg) { cv::imwrite(directory.str(), preview, jpg_params); std::cout<<"Saved to " << filename.str() <<std::endl; } if(view) { cv::imshow("Camera Viewer", preview); cv::waitKey(50); } } std::this_thread::sleep_for(std::chrono::milliseconds(250)); } //Finished photographing delete camera; } gps_thread.join(); closeLog(); return 0; }