void CAppParamParser::ParseArg(const CStdString &arg) { if (arg == "-fs" || arg == "--fullscreen") g_advancedSettings.m_startFullScreen = true; else if (arg == "-h" || arg == "--help") DisplayHelp(); else if (arg == "-v" || arg == "--version") DisplayVersion(); else if (arg == "--standalone") g_application.SetStandAlone(true); else if (arg == "-p" || arg == "--portable") g_application.EnablePlatformDirectories(false); else if (arg == "--debug") EnableDebugMode(); else if (arg == "--legacy-res") g_application.SetEnableLegacyRes(true); else if (arg == "--test") m_testmode = true; else if (arg.substr(0, 11) == "--settings=") g_advancedSettings.AddSettingsFile(arg.substr(11)); else if (arg.length() != 0 && arg[0] != '-') { if (m_testmode) g_application.SetEnableTestMode(true); CFileItemPtr pItem(new CFileItem(arg)); pItem->SetPath(arg); m_playlist.Add(pItem); } }
BOOL CDialog::OnInit(HWND hwnd) { TCHAR szCaption[MAX_PATH] = {0}; m_hwnd = hwnd; if( IsAlreadyInstalled() ) { if( IsSameVersion() ) m_bUnInstall = true; else m_bNewVersion = true; } // Set dialog icon, big and small ::SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(m_hInstance, MAKEINTRESOURCE(IDI_MAIN))); ::SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(m_hInstance, MAKEINTRESOURCE(IDI_MAIN))); // Set dialog caption int caption = m_bUnInstall ? IDS_CAPTION_UNINSTALL : IDS_CAPTION_INSTALL; ::LoadString(m_hInstance, caption, szCaption, sizeof(szCaption)); ::SetWindowText(hwnd, szCaption); DisplayVersion(); // Set dialog message if(m_bUnInstall) SetMessage( IDS_BODY_UNINSTALL ); else SetMessage( IDS_BODY_INSTALL, m_szDestinationPath ); return TRUE; }
static void DisplayUsage () { DisplayVersion (); g_print ("\nCommand-line options:\n\n"); g_print (" -d --distortion Apply lens distortion\n"); g_print (" -g# --geometry=# Convert image geometry to given (one of:\n"); g_print (" rectilinear,fisheye,panoramic,equirectangular,\n"); g_print (" orthographic, stereographic, equisolid, thoby)\n"); g_print (" -t --tca Apply lens chromatic aberrations\n"); g_print (" -v --vignetting Apply lens vignetting\n"); g_print (" -a --all Apply all possible corrections (tca, vign, dist)\n"); g_print (" -i --inverse Inverse correction of the image (e.g. simulate\n"); g_print (" lens distortions instead of correcting them)\n"); g_print ("\n"); g_print (" -C# --camera=# Camera name\n"); g_print (" -c# --crop=# Set camera crop factor in case the camera is not given\n"); g_print ("\n"); g_print (" -L# --lens=# Lens name to search for in the database\n"); g_print (" -F# --focal=# Set focal length at which image has been taken\n"); g_print (" -A# --aperture=# Set aperture at which image has been taken\n"); g_print (" -D# --distance=# Set subject distance at which image has been taken\n"); g_print ("\n"); g_print (" -s# --scale=# Apply additional scale on the image\n"); g_print (" -I# --interpol=# Choose interpolation algorithm (n[earest], b[ilinear], l[anczos])\n"); g_print ("\n"); g_print (" -o# --output=# Set file name for output image\n"); g_print (" --verbose Verbose output\n"); g_print (" --version Display program version and exit\n"); g_print (" -h --help Display this help text\n"); }
/***************************************************************** 函数原型: System_Init() 功能描述:器件类初始化 参数描述: 返回值: 无 作 者: 大连现代/刘及华 日 期: 2004-09-17 修改历史: 日期 修改人 修改描述 ------ --------- ------------- *****************************************************************/ void System_Init(void) { INT8U i; ToggleWD(); SetBell(OFF); SleepMs(200); Start_beep(); /* 开机后蜂鸣器提示*/ SleepMs(200); /* 全局变量初始化*/ //DevStat初始化 memset((void*)&DevStat, 0x00, sizeof(DevStat)); ReadParam(); DevStat.err_occured = FALSE; DevStat.err_code = 0x0000; DevStat.id = 0x10; DevStat.mode = AUTO; DevStat.passwd = 0; DevStat.MOD_REG.reg[0x0018] = 0x00; //禁止继电器动作 i = query_key_nsnd(); if ( i == KEY_CANCEL ) //开机时按下CANCEL键,进入格式化状态 { (void)Get_Passwd(); } memset(PageBuf1, 0xFF, sizeof(PageBuf1)); FlashPageRead512(10, PageBuf1, 0); memcpy((void *)&DevStat.reset_times, (void *)PageBuf1, sizeof(DevStat.reset_times)); if(DevStat.reset_times >= 254) { DevStat.reset_times = 0; } DevStat.reset_times++; memcpy((void *)PageBuf1, (void *)&DevStat.reset_times, sizeof(DevStat.reset_times)); FlashPageWrite512(10, PageBuf1, 0); DisplayTimeEN = TRUE; //允许刷新时间任务刷新时间 #ifdef QUICK_DEBUG #else DisplayVersion(VERSION); DisplayID(DevStat.id); SleepMs(1000); #endif }
PatcherOptions::PatcherOptions(int argc, char* argv[]) : m_displayHelp(false), m_displayVersion(false), m_interactive(true), m_patchToRealLength(false), m_timeInSeconds(105), m_lengthConditionType(condition_none), m_lengthCondition(120), m_startingPaths() { po::options_description desc = GetCmdOptions(); po::positional_options_description positionalOptions; positionalOptions.add("patchpaths", -1); po::variables_map vm; po::store(po::command_line_parser(argc, argv).options(desc).positional(positionalOptions).run(), vm); po::notify(vm); DisplayHelp(vm.count("help") > 0); DisplayVersion(vm.count("version") > 0); Interactive(vm.count("not-interactive") == 0); bool unpatch = vm.count("unpatch") > 0; bool patchall = vm.count("patchall") > 0; if(vm.count("patchpaths")) { SetStartingPaths(vm["patchpaths"].as<vector<string> >()); } else { StartingPaths().push_back(fs::initial_path().string()); } if(!unpatch) { TimeInSeconds(105); UseLengthGreaterThanCondition(120); } else { PatchToRealLength(); UseLengthEqualCondition(105); } if(patchall) { DontUseLengthCondition(); } }
bool ParseOptions(int argc, char** argv, std::string& configPath, bool& siteop, bool& raw, std::string& templatePath) { po::options_description visible("supported options"); visible.add_options() ("help,h", "display this help message") ("version,v", "display version") ("config-path,c", po::value<std::string>(&configPath), "specify location of config file") ("siteop,s", "site who") ("raw,r", "raw formatting") ("template,y", po::value<std::string>(&templatePath), "template file path") ; po::variables_map vm; try { po::store(po::command_line_parser(argc, argv).options(visible).run(), vm); if (vm.count("help")) { DisplayHelp(argv[0], visible); return false; } if (vm.count("version")) { DisplayVersion(); return false; } po::notify(vm); } catch (const po::error& e) { std::cerr << e.what() << std::endl; DisplayHelp(argv[0], visible); return false; } siteop = vm.count("siteop") > 0; raw = vm.count("raw") > 0; return true; }
VOID SysMgmtMain(VOID * pParam) { NST_TskMsg* pTaskMsg; #ifdef CPU_USAGE_STAT OSTimeDly(100); #endif // CPU_USAGE_STAT // DisplayVersion(); while (1) { if (NST_GetMsg(gpSysMngTskMsgQ, &pTaskMsg ) != OS_ERR_NONE) continue; if (pTaskMsg != NULL) { DefaultProc(pTaskMsg); NST_FreeTskMsg(pTaskMsg); } } }
bool ParseOptions(int argc, char** argv, bool& recursive, std::string& configPath, std::string& user, std::string& group, std::vector<std::string>& paths) { namespace po = boost::program_options; po::options_description visible("supported options"); visible.add_options() ("help,h", "display this help message") ("version,v", "display version") ("config-path,c", po::value<std::string>(), "specify location of config file") ("recursive,R", "apply changes recursively") ; std::string who; po::options_description all("positional options"); all.add(visible); all.add_options() ("who", po::value<std::string>(&who)->required(), "who") ("paths", po::value(&paths)->required(), "paths") ; po::positional_options_description pos; pos.add("who", 1); pos.add("paths", -1); po::variables_map vm; try { po::store(po::command_line_parser(argc, argv).options(all). positional(pos).run(), vm); if (vm.count("help")) { DisplayHelp(argv[0], visible); return false; } if (vm.count("version")) { DisplayVersion(); return false; } po::notify(vm); boost::smatch match; if (!boost::regex_match(who, match, boost::regex("(\\w+)?(?::(\\w+))?"))) throw boost::program_options::error("invalid user:group option specified"); user = match[1].str(); group = match[2].str(); if (user.empty() && group.empty()) throw boost::program_options::error("invalid user:group option specified"); } catch (const boost::program_options::error& e) { std::cerr << e.what() << std::endl; DisplayHelp(argv[0], visible); return false; } if (vm.count("config-path")) configPath = vm["config-path"].as<std::string>(); recursive = vm.count("recursive") > 0; return true; }
int main( int i_argc, char **pp_argv ) { const char *psz_network_name = "DVBlast - http://www.videolan.org/projects/dvblast.html"; char *p_network_name_tmp = NULL; size_t i_network_name_tmp_size; char *psz_dup_config = NULL; mtime_t i_poll_timeout = MAX_POLL_TIMEOUT; struct sched_param param; int i_error; int c; struct sigaction sa; sigset_t set; int b_enable_syslog = 0; if ( i_argc == 1 ) usage(); /* * The only short options left are: ky0123456789 * Use them wisely. */ static const struct option long_options[] = { { "config-file", required_argument, NULL, 'c' }, { "remote-socket", required_argument, NULL, 'r' }, { "ttl", required_argument, NULL, 't' }, { "rtp-output", required_argument, NULL, 'o' }, { "priority", required_argument, NULL, 'i' }, { "adapter", required_argument, NULL, 'a' }, { "frontend-number", required_argument, NULL, 'n' }, { "frequency", required_argument, NULL, 'f' }, { "fec-inner", required_argument, NULL, 'F' }, { "rolloff", required_argument, NULL, 'R' }, { "symbol-rate", required_argument, NULL, 's' }, { "diseqc", required_argument, NULL, 'S' }, { "voltage", required_argument, NULL, 'v' }, { "force-pulse", no_argument, NULL, 'p' }, { "bandwidth", required_argument, NULL, 'b' }, { "inversion", required_argument, NULL, 'I' }, { "modulation", required_argument, NULL, 'm' }, { "pilot", required_argument, NULL, 'P' }, { "fec-lp", required_argument, NULL, 'K' }, { "guard", required_argument, NULL, 'G' }, { "hierarchy", required_argument, NULL, 'H' }, { "transmission", required_argument, NULL, 'X' }, { "lock-timeout", required_argument, NULL, 'O' }, { "budget-mode", no_argument, NULL, 'u' }, { "select-pmts", no_argument, NULL, 'w' }, { "udp", no_argument, NULL, 'U' }, { "unique-ts-id", no_argument, NULL, 'T' }, { "latency", required_argument, NULL, 'L' }, { "retention", required_argument, NULL, 'E' }, { "duplicate", required_argument, NULL, 'd' }, { "rtp-input", required_argument, NULL, 'D' }, { "asi-adapter", required_argument, NULL, 'A' }, { "any-type", no_argument, NULL, 'z' }, { "dvb-compliance", no_argument, NULL, 'C' }, { "emm-passthrough", no_argument, NULL, 'W' }, { "ecm-passthrough", no_argument, NULL, 'Y' }, { "epg-passthrough", no_argument, NULL, 'e' }, { "network-name", no_argument, NULL, 'M' }, { "network-id", no_argument, NULL, 'N' }, { "system-charset", required_argument, NULL, 'j' }, { "dvb-charset", required_argument, NULL, 'J' }, { "provider-name", required_argument, NULL, 'B' }, { "logger", no_argument, NULL, 'l' }, { "logger-ident", required_argument, NULL, 'g' }, { "print", required_argument, NULL, 'x' }, { "quit-timeout", required_argument, NULL, 'Q' }, { "quiet", no_argument, NULL, 'q' }, { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, { "mrtg-file", required_argument, NULL, 'Z' }, { 0, 0, 0, 0 } }; while ( (c = getopt_long(i_argc, pp_argv, "q::c:r:t:o:i:a:n:f:F:R:s:S:v:pb:I:m:P:K:G:H:X:O:uwUTL:E:d:D:A:lg:zCWYeM:N:j:J:B:x:Q:hVZ:", long_options, NULL)) != -1 ) { switch ( c ) { case 'q': if ( optarg ) { if ( *optarg == 'q' ) /* e.g. -qqq */ { i_verbose--; while ( *optarg == 'q' ) { i_verbose--; optarg++; } } else { i_verbose -= atoi( optarg ); /* e.g. -q2 */ } } else { i_verbose--; /* -q */ } break; case 'c': psz_conf_file = optarg; break; case 'r': psz_srv_socket = optarg; break; case 't': i_ttl_global = strtol( optarg, NULL, 0 ); break; case 'o': { struct in_addr maddr; if ( !inet_aton( optarg, &maddr ) ) usage(); memcpy( pi_ssrc_global, &maddr.s_addr, 4 * sizeof(uint8_t) ); break; } case 'i': i_priority = strtol( optarg, NULL, 0 ); break; case 'a': i_adapter = strtol( optarg, NULL, 0 ); break; case 'n': i_fenum = strtol( optarg, NULL, 0 ); break; case 'f': i_frequency = strtol( optarg, NULL, 0 ); if ( pf_Open != NULL ) usage(); pf_Open = dvb_Open; pf_Read = dvb_Read; pf_Reset = dvb_Reset; pf_SetFilter = dvb_SetFilter; pf_UnsetFilter = dvb_UnsetFilter; break; case 'F': i_fec = strtol( optarg, NULL, 0 ); break; case 'R': i_rolloff = strtol( optarg, NULL, 0 ); break; case 's': i_srate = strtol( optarg, NULL, 0 ); break; case 'S': i_satnum = strtol( optarg, NULL, 16 ); break; case 'v': i_voltage = strtol( optarg, NULL, 0 ); break; case 'p': b_tone = 1; break; case 'b': i_bandwidth = strtol( optarg, NULL, 0 ); break; case 'I': i_inversion = strtol( optarg, NULL, 0 ); break; case 'm': psz_modulation = optarg; break; case 'P': i_pilot = strtol( optarg, NULL, 0 ); break; case 'K': i_fec_lp = strtol( optarg, NULL, 0 ); break; case 'G': i_guard = strtol( optarg, NULL, 0 ); break; case 'X': i_transmission = strtol( optarg, NULL, 0 ); break; case 'O': i_frontend_timeout_duration = strtoll( optarg, NULL, 0 ) * 1000; break; case 'H': i_hierarchy = strtol( optarg, NULL, 0 ); break; case 'u': b_budget_mode = 1; break; case 'w': b_select_pmts = 1; break; case 'U': b_udp_global = true; break; case 'L': i_latency_global = strtoll( optarg, NULL, 0 ) * 1000; break; case 'E': i_retention_global = strtoll( optarg, NULL, 0 ) * 1000; break; case 'd': psz_dup_config = optarg; break; case 'D': psz_udp_src = optarg; if ( pf_Open != NULL ) usage(); pf_Open = udp_Open; pf_Read = udp_Read; pf_Reset = udp_Reset; pf_SetFilter = udp_SetFilter; pf_UnsetFilter = udp_UnsetFilter; break; case 'A': i_asi_adapter = strtol( optarg, NULL, 0 ); if ( pf_Open != NULL ) usage(); pf_Open = asi_Open; pf_Read = asi_Read; pf_Reset = asi_Reset; pf_SetFilter = asi_SetFilter; pf_UnsetFilter = asi_UnsetFilter; break; case 'z': b_any_type = 1; break; case 'C': b_dvb_global = true; break; case 'W': b_enable_emm = true; break; case 'Y': b_enable_ecm = true; b_dvb_global = true; break; case 'e': b_epg_global = true; break; case 'M': psz_network_name = optarg; break; case 'N': i_network_id = strtoul( optarg, NULL, 0 ); break; case 'T': b_random_tsid = 1; break; case 'j': psz_native_charset = optarg; break; case 'J': psz_dvb_charset = optarg; break; case 'B': psz_provider_name = optarg; break; case 'l': b_enable_syslog = 1; break; case 'g': psz_syslog_ident = optarg; break; case 'x': if ( !strcmp(optarg, "text") ) i_print_type = PRINT_TEXT; else if ( !strcmp(optarg, "xml") ) i_print_type = PRINT_XML; else msg_Warn( NULL, "unrecognized print type %s", optarg ); /* Make stdout line-buffered */ setvbuf(stdout, NULL, _IOLBF, 0); break; case 'Q': i_quit_timeout_duration = strtoll( optarg, NULL, 0 ) * 1000; break; case 'V': DisplayVersion(); exit(0); break; case 'Z': psz_mrtg_file = optarg; break; case 'h': default: usage(); } } if ( optind < i_argc || pf_Open == NULL ) usage(); if ( b_enable_syslog ) msg_Connect( psz_syslog_ident ? psz_syslog_ident : pp_argv[0] ); if ( i_verbose ) DisplayVersion(); msg_Warn( NULL, "restarting" ); switch (i_print_type) { case PRINT_XML: printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); printf("<TS>\n"); break; default: break; } if ( b_udp_global ) { msg_Warn( NULL, "raw UDP output is deprecated. Please consider using RTP." ); msg_Warn( NULL, "for DVB-IP compliance you should use RTP." ); } if ( b_epg_global && !b_dvb_global ) { msg_Dbg( NULL, "turning on DVB compliance, required by EPG information" ); b_dvb_global = true; } memset( &output_dup, 0, sizeof(output_dup) ); if ( psz_dup_config != NULL ) { output_config_t config; config_Defaults( &config ); if ( !config_ParseHost( &config, psz_dup_config ) ) msg_Err( NULL, "Invalid target address for -d switch" ); else { output_Init( &output_dup, &config ); output_Change( &output_dup, &config ); } config_Free( &config ); } if ( strcasecmp( psz_native_charset, psz_dvb_charset ) ) { #ifdef HAVE_ICONV iconv_t iconv_system = iconv_open( psz_dvb_charset, psz_native_charset ); if ( iconv_system != (iconv_t)-1 ) { size_t i = strlen( psz_network_name ); char *p, *psz_string; i_network_name_tmp_size = i * 6; p = psz_string = malloc(i_network_name_tmp_size); if ( iconv( iconv_system, (char **)&psz_network_name, &i, &p, &i_network_name_tmp_size ) == -1 ) free( psz_string ); else { p_network_name_tmp = psz_string; i_network_name_tmp_size = p - psz_string; } iconv_close( iconv_system ); } #else msg_Warn( NULL, "unable to convert from %s to %s (iconv is not available)", psz_native_charset, psz_dvb_charset ); #endif } if ( p_network_name_tmp == NULL ) { p_network_name_tmp = strdup(psz_network_name); i_network_name_tmp_size = strlen(psz_network_name); } p_network_name = dvb_string_set( (uint8_t *)p_network_name_tmp, i_network_name_tmp_size, psz_dvb_charset, &i_network_name_size ); free( p_network_name_tmp ); /* Set signal handlers */ memset( &sa, 0, sizeof(struct sigaction) ); sa.sa_handler = SigHandler; sigfillset( &set ); if ( sigaction( SIGHUP, &sa, NULL ) == -1 || sigaction( SIGINT, &sa, NULL ) == -1 ) { msg_Err( NULL, "couldn't set signal handler: %s", strerror(errno) ); exit(EXIT_FAILURE); } srand( time(NULL) * getpid() ); demux_Open(); // init the mrtg logfile mrtgInit(psz_mrtg_file); if ( i_priority > 0 ) { memset( ¶m, 0, sizeof(struct sched_param) ); param.sched_priority = i_priority; if ( (i_error = pthread_setschedparam( pthread_self(), SCHED_RR, ¶m )) ) { msg_Warn( NULL, "couldn't set thread priority: %s", strerror(i_error) ); } } config_ReadFile( psz_conf_file ); if ( psz_srv_socket != NULL ) comm_Open(); for ( ; ; ) { block_t *p_ts; if ( b_exit_now ) { msg_Info( NULL, "Shutdown was requested." ); break; } if ( b_conf_reload ) { b_conf_reload = 0; msg_Info( NULL, "Configuration reload was requested." ); config_ReadFile( psz_conf_file ); } if ( i_quit_timeout && i_quit_timeout <= i_wallclock ) { switch (i_print_type) { case PRINT_XML: printf("</TS>\n"); break; default: break; } exit(EXIT_SUCCESS); } p_ts = pf_Read( i_poll_timeout ); if ( p_ts != NULL ) { mrtgAnalyse(p_ts); demux_Run( p_ts ); } i_poll_timeout = output_Send(); if ( i_poll_timeout == -1 || i_poll_timeout > MAX_POLL_TIMEOUT ) i_poll_timeout = MAX_POLL_TIMEOUT; } mrtgClose(); outputs_Close( i_nb_outputs ); demux_Close(); free( p_network_name ); if ( b_enable_syslog ) msg_Disconnect(); if ( psz_srv_socket && i_comm_fd > -1 ) unlink( psz_srv_socket ); return EXIT_SUCCESS; }
/***************************************************************************** * Entry point *****************************************************************************/ void usage() { DisplayVersion(); msg_Raw( NULL, "Usage: dvblast [-q] [-c <config file>] [-r <remote socket>] [-t <ttl>] [-o <SSRC IP>] " "[-i <RT priority>] " #ifdef HAVE_ASI_SUPPORT "[-A <ASI adapter>]" #endif #ifdef HAVE_DVB_SUPPORT "[-a <adapter>] [-n <frontend number>] [-S <diseqc>] [-k <uncommitted port>]" "[-f <frequency>]" "[-s <symbol rate>] [-v <0|13|18>] [-p] [-b <bandwidth>] [-I <inversion>] " "[-F <fec inner>] [-m <modulation] [-R <rolloff>] [-P <pilot>] [-K <fec lp>] " "[-G <guard interval>] [-H <hierarchy>] [-X <transmission>] [-O <lock timeout>] " #endif "[-D [<src host>[:<src port>]@]<src mcast>[:<port>][/<opts>]*] " "[-u] [-w] [-U] [-L <latency>] [-E <retention>] [-d <dest IP>[<:port>][/<opts>]*] [-3] " "[-z] [-C [-e] [-M <network name>] [-N <network ID>]] [-T] [-j <system charset>] " "[-W] [-Y] [-l] [-g <logger ident>] [-Z <mrtg file>] [-V] [-h] [-B <provider_name>] " "[-1 <mis_id>] [-2 <size>] [-5 <DVBS|DVBS2|DVBC_ANNEX_A|DVBT|DVBT2|ATSC>] -y <ca_dev_number> " "[-J <DVB charset>] [-Q <quit timeout>] [-0 pid_mapping] [-x <text|xml>]" "[-6 <print period>] [-7 <ES timeout>]" ); msg_Raw( NULL, "Input:" ); #ifdef HAVE_ASI_SUPPORT msg_Raw( NULL, " -A --asi-adapter read packets from an ASI adapter (0-n)" ); #endif #ifdef HAVE_DVB_SUPPORT msg_Raw( NULL, " -a --adapter read packets from a Linux-DVB adapter (typically 0-n)" ); msg_Raw( NULL, " -b --bandwidth frontend bandwidth" ); #endif msg_Raw( NULL, " -D --rtp-input read packets from a multicast address instead of a DVB card" ); #ifdef HAVE_DVB_SUPPORT msg_Raw( NULL, " -5 --delsys delivery system" ); msg_Raw( NULL, " DVBS|DVBS2|DVBC_ANNEX_A|DVBT|ATSC (default guessed)"); msg_Raw( NULL, " -f --frequency frontend frequency" ); msg_Raw( NULL, " -9 --dvb-plp-id <number> Switch PLP of the DVB-T2 transmission (for Russia special)" ); msg_Raw( NULL, " -F --fec-inner Forward Error Correction (FEC Inner)"); msg_Raw( NULL, " DVB-S2 0|12|23|34|35|56|78|89|910|999 (default auto: 999)"); msg_Raw( NULL, " -I --inversion Inversion (-1 auto, 0 off, 1 on)" ); msg_Raw( NULL, " -m --modulation Modulation type" ); msg_Raw( NULL, " DVB-C qpsk|qam_16|qam_32|qam_64|qam_128|qam_256 (default qam_auto)" ); msg_Raw( NULL, " DVB-T qam_16|qam_32|qam_64|qam_128|qam_256 (default qam_auto)" ); msg_Raw( NULL, " DVB-S2 qpsk|psk_8 (default legacy DVB-S)" ); msg_Raw( NULL, " -n --frontend-number <frontend number>" ); msg_Raw( NULL, " -p --force-pulse force 22kHz pulses for high-band selection (DVB-S)" ); msg_Raw( NULL, " -P --pilot DVB-S2 Pilot (-1 auto, 0 off, 1 on)" ); msg_Raw( NULL, " -R --rolloff DVB-S2 Rolloff value" ); msg_Raw( NULL, " DVB-S2 35=0.35|25=0.25|20=0.20|0=AUTO (default: 35)" ); msg_Raw( NULL, " -1 --multistream-id Set stream ID (0-255, default: 0)" ); msg_Raw( NULL, " -K --fec-lp DVB-T low priority FEC (default auto)" ); msg_Raw( NULL, " -G --guard DVB-T guard interval" ); msg_Raw( NULL, " DVB-T 32 (1/32)|16 (1/16)|8 (1/8)|4 (1/4)|-1 (auto, default)" ); msg_Raw( NULL, " -H --hierarchy DVB-T hierarchy (0, 1, 2, 4 or -1 auto, default)" ); msg_Raw( NULL, " -X --transmission DVB-T transmission (2, 4, 8 or -1 auto, default)" ); msg_Raw( NULL, " -s --symbol-rate" ); msg_Raw( NULL, " -S --diseqc satellite number for diseqc (0: no diseqc, 1-4, A or B)" ); msg_Raw( NULL, " -k --uncommitted port number for uncommitted diseqc (0: no uncommitted diseqc, 1-4)" ); msg_Raw( NULL, " -u --budget-mode turn on budget mode (no hardware PID filtering)" ); msg_Raw( NULL, " -v --voltage voltage to apply to the LNB (QPSK)" ); msg_Raw( NULL, " -w --select-pmts set a PID filter on all PMTs (auto on, when config file is used)" ); msg_Raw( NULL, " -O --lock-timeout timeout for the lock operation (in ms)" ); msg_Raw( NULL, " -y --ca-number <ca_device_number>" ); msg_Raw( NULL, " -2 --dvr-buf-size <size> set the size of the DVR TS buffer in bytes (default: %d)", i_dvr_buffer_size); #endif msg_Raw( NULL, "Output:" ); msg_Raw( NULL, " -c --config-file <config file>" ); msg_Raw( NULL, " -C --dvb-compliance pass through or build the mandatory DVB tables" ); msg_Raw( NULL, " -d --duplicate duplicate all received packets to a given destination" ); msg_Raw( NULL, " -3 --passthrough duplicate all received packets to stdout" ); msg_Raw( NULL, " -W --emm-passthrough pass through EMM data (CA system data)" ); msg_Raw( NULL, " -Y --ecm-passthrough pass through ECM data (CA program data)" ); msg_Raw( NULL, " -e --epg-passthrough pass through DVB EIT schedule tables" ); msg_Raw( NULL, " -E --retention maximum retention allowed between input and output (default: 40 ms)" ); msg_Raw( NULL, " -L --latency maximum latency allowed between input and output (default: 100 ms)" ); msg_Raw( NULL, " -M --network-name DVB network name to declare in the NIT" ); msg_Raw( NULL, " -N --network-id DVB network ID to declare in the NIT" ); msg_Raw( NULL, " -B --provider-name Service provider name to declare in the SDT" ); msg_Raw( NULL, " -o --rtp-output <SSRC IP>" ); msg_Raw( NULL, " -t --ttl <ttl> TTL of the output stream" ); msg_Raw( NULL, " -T --unique-ts-id generate random unique TS ID for each output" ); msg_Raw( NULL, " -U --udp use raw UDP rather than RTP (required by some IPTV set top boxes)" ); msg_Raw( NULL, " -z --any-type pass through all ESs from the PMT, of any type" ); msg_Raw( NULL, " -0 --pidmap <pmt_pid,audio_pid,video_pid,spu_pid>"); msg_Raw( NULL, "Misc:" ); msg_Raw( NULL, " -h --help display this full help" ); msg_Raw( NULL, " -i --priority <RT priority>" ); msg_Raw( NULL, " -j --system-charset character set used for printing messages (default UTF-8)" ); msg_Raw( NULL, " -J --dvb-charset character set used in output DVB tables (default UTF-8)" ); msg_Raw( NULL, " -l --logger use syslog for logging messages instead of stderr" ); msg_Raw( NULL, " -g --logger-ident program name that will be used in syslog messages" ); msg_Raw( NULL, " -x --print print interesting events on stdout in a given format" ); msg_Raw( NULL, " -q --quiet be quiet (less verbosity, repeat or use number for even quieter)" ); msg_Raw( NULL, " -Q --quit-timeout when locked, quit after this delay (in ms), or after the first lock timeout" ); msg_Raw( NULL, " -6 --print-period periodicity at which we print bitrate and errors (in ms)" ); msg_Raw( NULL, " -7 --es-timeout time of inactivy before which a PID is reported down (in ms)" ); msg_Raw( NULL, " -r --remote-socket <remote socket>" ); msg_Raw( NULL, " -Z --mrtg-file <file> Log input packets and errors into mrtg-file" ); msg_Raw( NULL, " -V --version only display the version" ); exit(1); }
bool CCommandParser::ParseParam(int argc, const char**argv, CParameterList* aParamList) { if (argc < 2) { throw CCommandParser::ECmdLineUnknownOption; } bool bContinue = true; while ((--argc > 0) && bContinue) { ++argv; if (**argv != '-') { continue; } bool err = false; const char* optPtr = *argv; switch (toupper(*++optPtr)) { #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK case 'A': { if (argc <= 1) throw CCommandParser::ECmdLineNoDirArgument; --argc; aParamList->SetResourceFilePath(*(++argv)); break; } #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK case 'C': { if (argc <= 1) throw CCommandParser::ECmdLineNoDirArgument; --argc; aParamList->SetSystemDrive(*(++argv)); break; } case 'D': { --argc; wchar_t buf[2048]; ConvertMultiByteToWideChar(*++argv,-1, buf, 2048); aParamList->SetSystemDriveLetter(tolower(buf[0])); break; } case 'E': { aParamList->SetFlag(CParameterList::EFlagsDisableZDriveChecksSet); break; } #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK case 'F': { aParamList->SetOriginVerificationStatus(false); break; } #endif case 'H': case '?': { DisplayUsage(); bContinue = false; break; } case 'I': { if (argc <= 1) throw CCommandParser::ECmdLineNoConfigFileArgument; --argc; aParamList->SetConfigFile(*(++argv)); break; } case 'K': { // Last command if (argc == 1) { aParamList->SetSisRegistryVersion(SisRegistry::KRegistryV40string); } else { // Check that the next arg is valid std::string versionStr = *(++argv); if (**argv == '-') { aParamList->SetSisRegistryVersion(SisRegistry::KRegistryV40string); --argv; } else { --argc; aParamList->SetSisRegistryVersion(versionStr); } } break; } case 'L': { if (argc > 1) { --argc; wchar_t buf[2048]; ConvertMultiByteToWideChar(*++argv,-1, buf, 2048); iLogFile = buf; } break; } case 'N': { if (argc <= 1) throw CCommandParser::ECmdLineInvalidLanguage; --argc; aParamList->SetLanguage(static_cast< CSISLanguage::TLanguage >( String2Language( *(++argv) ) )); break; } case 'O': { DisplayOpenSSLCopyright(); bContinue = false; break; } case 'P': { if (!(err = argc <= 1)) { --argc; std::string paramFile = *(++argv); ParseParam(argc, paramFile, aParamList); } break; } case 'R': { if (argc <= 1) throw CCommandParser::ECmdLineNoRomRofsLogsArgument; --argc; aParamList->EmptyRomLogFiles(); #ifdef _MSC_VER FilePtr funtionPtr = aParamList->AddRomLogFile; #else FilePtr funtionPtr = &(aParamList->AddRomLogFile); #endif // _MSC_VER String2List(*aParamList, funtionPtr, *(++argv) ); break; } case 'S': { if (argc <= 1) throw CCommandParser::ECmdLineNoSisArgument; --argc; String2SISFileList(*aParamList, argc, ++argv); break; } case 'T': { if (argc <= 1) throw CCommandParser::ECmdLineNoSisStubPathArgument; --argc; aParamList->SetStubDir(*(++argv)); break; } case 'V': { DisplayVersion(); bContinue = false; break; } case 'W': { --argc; iWarnLevel = String2Warn(*(++argv)); break; } case 'X': { if (argc <= 1) throw CCommandParser::ECmdLineMissingPackageUID; --argc; aParamList->EmptyPkgUids(); #ifdef _MSC_VER FilePtr funtionPtr = (aParamList->AddPkgUid); #else FilePtr funtionPtr = &(aParamList->AddPkgUid); #endif // _MSC_VER String2List(*aParamList, funtionPtr, *(++argv) ); break; } case 'Z': { if (argc <= 1) throw CCommandParser::ECmdLineNoDirArgument; --argc; aParamList->SetZDrive(*(++argv)); break; } default: { LERROR(string2wstring(std::string(optPtr))); throw CCommandParser::ECmdLineUnknownOption; } } if (err) { throw CCommandParser::ECmdLineUnknownOption; } } // Finished parsing all the command line options return !bContinue; }
void CCommandParser::DisplayUsage() { DisplayVersion(); std::cout #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK << "Usage: " << CommandName () << " [-z dir] [-c dir] [-e] [-f] [-k [4.0 | 5.0 | 5.1 | 5.2 | 5.3 | 5.4]]\n" #else << "Usage: " << CommandName () << " [-z dir] [-c dir] [-e] [-k [4.0 | 5.0 | 5.1 | 5.2 | 5.3 | 5.4]]\n" #endif << "\t\t[-s [sisfile | dir] [+drive [+mcard | +mcardnr | +nonremovablepkg | +mcardalone | +mcardalonenr] [+sucert]]] [-s ...]\n" << "\t\t[-p param_file] [-d drive] [-r rofsbuild_log_file1,rofsbuild_log_file2,...]\n" << "\t\t[-t romstubdir] [-n language_code] [-i config_file] \n" << "\t\t[-x pkgUID[,pkgUID2,...]] [-w [off | error | warn | info]] [-l logfile]\n\n" << "Where:\t-h\t\tDisplays help\n" #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK << "\t-a\t\tThe path representing the location of Resource files\n" << "\t \t\tSpecifying the ROM Drive (-z) is mandatory.\n" << "\t \t\tLocalize resource file is read from (Rom_drive\\path_specified_in_resource_file)\n" #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK << "\t-c\t\tThe directory representing the system drive on the device\n" << "\t-d\t\tThe system drive letter [default to 'C']\n" << "\t-e\t\tDisable eclipsing and SID checks using Z drive \n" << "\t \t\t-z or -r not required when this option used \n" #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK << "\t-f\t\tUsed to specify that origin of a component has not been verified during installation.\n" << "\t\t\tBy default the origin is verified. This option should not be provided along with registry version information.\n" #endif << "\t-i\t\tConfig file with HAL attribute values for installation \n"; std::cout #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK << "\t-k\t\tSIS Registry version to generate (default is to generate the db related registry entry) \n" #else << "\t-k\t\tSIS Registry version to generate (default v" << SisRegistry::KSisRegistryMajorVersion << "." << SisRegistry::KSisRegistryMinorVersion << ") \n" #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK << "\t-l\t\tThe file to write diagnostics to (stderr by default)\n" << "\t-n\t\tLanguage code - decimal number as defined in TLanguage enum\n" << "\t-o\t\tOutput licence information\n" << "\t-p\t\tA file to take additional parameters from.\n" << "\t \t\tCommand line args after the file will override the file contents\n" << "\t-r\t\tList of rom/rofs build log files; should not use with -z option or\n" << "\t \t\tdefine the Z drive in the config file\n" << "\t-s\t\tThe SIS file(s) to install. Any directory passed in will be searched\n" << "\t\t\tfor SIS files; should not use with -x option\n" << "\t-t\t\tROM Stub sis files directory, must be used with -r option\n" << "\t-v\t\tDisplays the version of the tool\n" << "\t-w\t\tThe level of diagnostics to display- WARN, ERROR, INFO, OFF\n" << "\t \t\t(warn by default)\n" << "\t-x\t\tRemove the files installed of a package; should not use with -s option\n" << "\t-z\t\tThe directory representing the Z: drive on the device\n" << "\tpkgUID\t\tThe installed package UID either in Hex or Decimal format (e.g. 0x12345678, 305419896)\n" << "\tsisfile\t\tThe SIS file to be installed\n" << "\tdir\t\tThe directory that contains the installing SIS files\n" << "\tdrive\t\tThe drive letter on the device\n" << "\tmcard\t\tOption to generate the stub SIS file for the installing package\n" << "\tmcardnr\t\tOption to generate the non-removable stub SIS file for the installing package\n" << "\tnonremovablepkg\tOption to generate the non-removable SIS file for the installing package\n\n" << "\tmcardalone\tOption to just create a pre-installed package to the media card\n" << "\tmcardalonenr\tOption to generate the non-removable stub SIS file for the installing" << std::endl << "\t\t\tpackage without generating the SISregistry entry\n" << "\tsucert\t\tTo indicate that the SIS file has been signed with a SU certificate\n\n"; }
static bool ParseParameters(int argc, char **argv) { static struct option long_options[] = { {"output", required_argument, NULL, 'o'}, {"distortion", no_argument, NULL, 'd'}, {"geometry", optional_argument, NULL, 'g'}, {"tca", no_argument, NULL, 't'}, {"vignetting", no_argument, NULL, 'v'}, {"all", no_argument, NULL, 'a'}, {"inverse", no_argument, NULL, 'i'}, {"scale", required_argument, NULL, 'S'}, {"lens", required_argument, NULL, 'L'}, {"camera", required_argument, NULL, 'C'}, {"crop", required_argument, NULL, 'c'}, {"focal", required_argument, NULL, 'F'}, {"aperture", required_argument, NULL, 'A'}, {"distance", required_argument, NULL, 'D'}, {"interpol", required_argument, NULL, 'I'}, {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 4}, {"verbose", no_argument, NULL, 5}, {0, 0, 0, 0} }; opts.Program = argv [0]; int c; while ((c = getopt_long (argc, argv, "o:dg::tvaiS:L:C:c:F:A:D:I:h", long_options, NULL)) != EOF) { switch (c) { case 'o': opts.Output = optarg; break; case 'd': opts.ModifyFlags |= LF_MODIFY_DISTORTION; break; case 'g': opts.ModifyFlags |= LF_MODIFY_GEOMETRY; if (optarg) { if (!strcasecmp (optarg, "rectilinear")) opts.TargetGeom = LF_RECTILINEAR; else if (!strcasecmp (optarg, "fisheye")) opts.TargetGeom = LF_FISHEYE; else if (!strcasecmp (optarg, "panoramic")) opts.TargetGeom = LF_PANORAMIC; else if (!strcasecmp (optarg, "equirectangular")) opts.TargetGeom = LF_EQUIRECTANGULAR; else if (!strcasecmp (optarg, "orthographic")) opts.TargetGeom = LF_FISHEYE_ORTHOGRAPHIC; else if (!strcasecmp (optarg, "stereographic")) opts.TargetGeom = LF_FISHEYE_STEREOGRAPHIC; else if (!strcasecmp (optarg, "equisolid")) opts.TargetGeom = LF_FISHEYE_EQUISOLID; else if (!strcasecmp (optarg, "thoby")) opts.TargetGeom = LF_FISHEYE_THOBY; else { DisplayUsage(); g_print ("\nTarget lens geometry must be one of 'rectilinear', 'fisheye', 'panoramic', 'equirectangular'\n'orthographic', 'stereographic', 'equisolid', 'thoby'\n"); return false; } } break; case 't': opts.ModifyFlags |= LF_MODIFY_TCA; break; case 'v': opts.ModifyFlags |= LF_MODIFY_VIGNETTING; break; case 'a': opts.ModifyFlags |= LF_MODIFY_VIGNETTING; opts.ModifyFlags |= LF_MODIFY_TCA; opts.ModifyFlags |= LF_MODIFY_DISTORTION; break; case 'i': opts.Inverse = true; break; case 'S': opts.ModifyFlags |= LF_MODIFY_SCALE; opts.Scale = _atof (optarg); break; case'L': opts.Lens = optarg; break; case'C': opts.Camera = optarg; break; case 'c': opts.Crop = _atof (optarg); break; case 'F': opts.Focal = _atof (optarg); break; case 'A': opts.Aperture = _atof (optarg); break; case 'D': opts.Distance = _atof (optarg); break; case 'I': if (smartstreq (optarg, "nearest")) opts.Interpolation = Image::I_NEAREST; else if (smartstreq (optarg, "bilinear")) opts.Interpolation = Image::I_BILINEAR; else if (smartstreq (optarg, "lanczos")) opts.Interpolation = Image::I_LANCZOS; else { DisplayUsage(); g_print ("\nUnknown interpolation method `%s'\n", optarg); return false; } break; case 'h': DisplayUsage (); return false; case 4: DisplayVersion (); return false; case 5: opts.Verbose = true; break; default: return false; } } if (optind <= argc) opts.Input = argv [optind]; if (!opts.Lens && !opts.Camera) { DisplayUsage(); g_print ("\nAt least a lens or camera name is required to perform a database lookup!\n"); return false; } if (!opts.Lens && opts.Input) { DisplayUsage(); g_print ("\nNo lens information (-L) supplied to process specified input image!\n"); return false; } return true; }
/* main - main program * * Parameters: * argc - number of command line arguments * argv - pointer to command line argument array * * Returns: * none */ int main(int argc, char **argv) { DATABASE_S_T data; /* main database */ SURNAME_T surname; /* surname string */ BOOLEAN_T is_interactive = FALSE; BOOLEAN_T is_file_list_given = FALSE; BOOLEAN_T do_processing = TRUE; char prog_name[64]; char file_list_name[64]; int i, parse_count; // get program's name // strcpy( prog_name, argv[0] ); // parse command line arguments // switch (argc) { case 1: is_interactive = TRUE; break; default: i = 1; while (i < argc) { if (argv[i][0] == '-') { switch(argv[i][1]) { case 'f': is_file_list_given = TRUE; if ( argc == (i+2) ) { strcpy( file_list_name, argv[i+1] ); i++; do_processing = TRUE; } else { ErrorUsage(prog_name); exit(1); } break; case 'h': ErrorUsage(prog_name); do_processing = FALSE; break; case 'v': do_processing = FALSE; break; default: ErrorUsage(prog_name); exit(1); break; } /* end of inner switch */ } else { strcpy( data.surname, argv[i] ); data.list.count = 1; } i++; /* increment arg index */ } /* end while */ break; } /* end of outer switch */ DisplayVersion( prog_name ); // get surname interactively from user // if ( is_interactive ) { printf("\nEnter surname: "); fgets( surname, MAX_SURNAME_LENGTH, stdin); strcpy( data.surname, surname ); data.surname[ strlen(surname) - 1 ] = 0; data.list.count = 1; } // read surnames from list // if ( is_file_list_given ) { if ( OpenSurnameListFile( file_list_name, &data ) ) { ErrorOpenFile( file_list_name ); } else { ReadSurnameListFile( &data ); #ifdef DEBUG OutputSurnameList( &data ); #endif CloseSurnameListFile( &data ); } } // parse surname or the surname list // if ( do_processing ) { parse_count = data.list.count; printf("\nSoundex output:\n"); for (i = 0; i < parse_count; i++) { // if we have a list, take next surname from list if ( parse_count > 1 ) { strcpy(data.surname, data.list.surname[i]); } ParseSurname( &data ); DisplaySoundex( &data ); } } return(0); }
//****************************************************************************** // // This function will parse the command line arguments, storing any needed // information in the appropriate variables for later reference. The // "getopts" command line processing library functions are used to parse // the command line options. The options are defined in accordance with // the GNU coding standard. // //****************************************************************************** static void ParseOptions(int argc, char **argv) { struct option sLongOptions[] = { // // GNU Standard Options that set a flag for program operation. // {"quiet", no_argument, &g_iOptVerbose, 0}, {"silent", no_argument, &g_iOptVerbose, 0}, {"verbose", no_argument, &g_iOptVerbose, 2}, // // GNU Standard options that simply display information and exit. // {"help", no_argument, 0, 0x100}, {"version", no_argument, 0, 0x101}, // // Program specific options that set variables and/or require arguments. // {"mac", required_argument, 0, 'm'}, {"ip", required_argument, 0, 'i'}, // // Terminating Element of the array // {0, 0, 0, 0} }; int iOptionIndex = 0; int iOption; int iReturnCode; // // Continue parsing options till there are no more to parse. // Note: The "m:i" allows the short and long options to be // used for the file, mac and ip parameters and will be processed // below by the same case statement. // while((iOption = getopt_long(argc, argv, "m:i:", sLongOptions, &iOptionIndex)) != -1) { // // Process the current option. // switch(iOption) { // // Long option with flag set. // case 0: break; // // --help // case 0x100: DisplayHelp(); exit(0); break; // // --version // case 0x101: DisplayVersion(); exit(0); break; // // --mac=string, -m string // case 'm': iReturnCode = AddressToBytes(optarg, g_pucRemoteMAC, 6, 16); if(iReturnCode != 6) { EPRINTF(("Error Processing MAC (%d)\n", iReturnCode)); DisplayHelp(); exit(-(__LINE__)); } break; // // --ip=string, -i string // case 'i': iReturnCode = AddressToBytes(optarg, &g_ulRemoteAddress, 4, 10); if(iReturnCode != 4) { EPRINTF(("Error Processing IP (%d)\n", iReturnCode)); DisplayHelp(); exit(-(__LINE__)); } break; // // Unrecognized option. // default: DisplayVersion(); DisplayHelp(); exit(-(__LINE__)); break; } } // // Extract filename from the last argument on the command line (if // provided). // if(optind == argc) { EPRINTF(("No File Name Specified\n")); DisplayHelp(); exit(-(__LINE__)); } else if(optind > (argc -1)) { EPRINTF(("Too Many Command Line Options\n")); DisplayHelp(); exit(-(__LINE__)); } else { g_pcFileName = argv[optind]; } // // Check for non-zero MAC address. // if((0 == g_pucRemoteMAC[0]) && (0 == g_pucRemoteMAC[1]) && (0 == g_pucRemoteMAC[2]) && (0 == g_pucRemoteMAC[3]) && (0 == g_pucRemoteMAC[4]) && (0 == g_pucRemoteMAC[5])) { EPRINTF(("No MAC Address Specified\n")); DisplayHelp(); exit(-(__LINE__)); } // // Check for non-zero IP address. // if(0 == g_ulRemoteAddress) { EPRINTF(("No IP Address Specified\n")); DisplayHelp(); exit(-(__LINE__)); } }
Options::Options (int argc, wchar_t** argv) : iVerboseFlag (false), iVersion (false), iHelpFlag (false), iExtractFilesFlag (false), iPauseOnExit (false), iList(false), iCreateECI(false) { while (--argc) { argv++; // WINDOWS ENVIRONMENT : If the underlying platform is WINDOWS then, // cope up with multiple arguments following the '-' or '/'. // // LINUX ENVIRONMENT : If the underlying platform is LINUX then, cope // up with multiple arguments following only the '-'. This restriction // of not dealing with arguments following '/' is due to the fact that, // the absolute paths in case of LINUX start with a '/'. So, this could // be mistaken as an option if we treat anything prefixed by a '/' as // an option. Hence, this facility is being removed once for all and // only '-' can(should) be used for specifying an option. if ( (**argv == '-') #ifndef __TOOLS2_LINUX__ || (**argv == '/') #endif ) { const wchar_t* optPtr = *argv; while (*++optPtr) { switch (*optPtr) { case 'd': case 'D': if (argc > 1) { argc--; iExtractDirectory = *(++argv); } else { throw ECmdLineNoDirArgument; } break; case 'h': case 'H': case '?': iHelpFlag = true; break; case 'v': case 'V': iVersion = true; break; case 'p': case 'P': iPauseOnExit = true; break; case 'i': case 'I': iVerboseFlag = true; break; case 'x': case 'X': iExtractFilesFlag = true; break; case 'l': case 'L': iList = true; break; case 'y': case 'Y': iCreateECI = true; break; default: throw ECmdLineUnknownOption; } } } else { if (iSISFileName != L"") { throw ECmdLineMultipleSIS; } else { iSISFileName = *argv; } } } if (iHelpFlag) { DisplayUsage (); if (iSISFileName == L"") // If we were asked for help then we shouldn't { // complain that there's no SIS file specified, exit (0); // just exit quietly. } } if (iVersion) { DisplayVersion (); if (iSISFileName == L"") { exit (0); } } if (iSISFileName == L"") { throw ECmdLineMissingSIS; } // Sanity check the directory argument // If directory name is not provided then // generate a directory name. GetExtractDir(); }
//***************************************************************************** // // Main entry. Process command line options, and start the bootp_server. // //***************************************************************************** int main(int argc, char **argv) { HOSTENT *pHostEnt; WSADATA wsaData; unsigned long ulLocalAddress; // // Parse the command line options. // if(argc > 1) { ParseOptions(argc, argv); } else { DisplayVersion(); DisplayHelp(); return(0); } // // Display (if needed) verbose function entry. // if(g_iOptVerbose > 1) { DisplayVersion(); } // // Install an abort handler. // signal(SIGINT, SignalIntHandler); // // Startup winsock. // VPRINTF(("Starting WINSOCK\n")); if(WSAStartup(0x202, &wsaData) != 0) { EPRINTF(("Winsock Failed to Start\n")); WSACleanup(); return(1); } // // Determine what my local IP address is. // pHostEnt = gethostbyname(""); ulLocalAddress = ((struct in_addr *)*pHostEnt->h_addr_list)->s_addr; // // Start the BOOTP/TFTP server to perform an update. // QPRINTF(("Starting BOOTP/TFTP Server ...\n")); StatusCallback(0); StartBOOTPUpdate(g_pucRemoteMAC, ulLocalAddress, g_ulRemoteAddress, g_pcFileName, StatusCallback); // // Cleanup winsock. // VPRINTF(("Closing WINSOCK\n")); WSACleanup(); // // Clean up and return. // if(g_bAbortMain) { return(2); } return(0); }
int main( int i_argc, char **pp_argv ) { const char *psz_network_name = "DVBlast - http://www.videolan.org/projects/dvblast.html"; const char *psz_provider_name = NULL; char *psz_dup_config = NULL; struct sched_param param; int i_error; int c; int b_enable_syslog = 0; struct ev_signal sigint_watcher, sigterm_watcher, sighup_watcher; struct ev_timer quit_watcher; print_fh = stdout; if ( i_argc == 1 ) usage(); /* * The only short options left are: 489 * Use them wisely. */ static const struct option long_options[] = { { "config-file", required_argument, NULL, 'c' }, { "remote-socket", required_argument, NULL, 'r' }, { "ttl", required_argument, NULL, 't' }, { "rtp-output", required_argument, NULL, 'o' }, { "priority", required_argument, NULL, 'i' }, { "adapter", required_argument, NULL, 'a' }, { "frontend-number", required_argument, NULL, 'n' }, { "delsys", required_argument, NULL, '5' }, { "dvb-plp-id", required_argument, NULL, '9' }, { "frequency", required_argument, NULL, 'f' }, { "fec-inner", required_argument, NULL, 'F' }, { "rolloff", required_argument, NULL, 'R' }, { "symbol-rate", required_argument, NULL, 's' }, { "diseqc", required_argument, NULL, 'S' }, { "uncommitted", required_argument, NULL, 'k' }, { "voltage", required_argument, NULL, 'v' }, { "force-pulse", no_argument, NULL, 'p' }, { "bandwidth", required_argument, NULL, 'b' }, { "inversion", required_argument, NULL, 'I' }, { "modulation", required_argument, NULL, 'm' }, { "pilot", required_argument, NULL, 'P' }, { "multistream-id", required_argument, NULL, '1' }, { "fec-lp", required_argument, NULL, 'K' }, { "guard", required_argument, NULL, 'G' }, { "hierarchy", required_argument, NULL, 'H' }, { "transmission", required_argument, NULL, 'X' }, { "lock-timeout", required_argument, NULL, 'O' }, { "budget-mode", no_argument, NULL, 'u' }, { "select-pmts", no_argument, NULL, 'w' }, { "udp", no_argument, NULL, 'U' }, { "unique-ts-id", no_argument, NULL, 'T' }, { "latency", required_argument, NULL, 'L' }, { "retention", required_argument, NULL, 'E' }, { "duplicate", required_argument, NULL, 'd' }, { "passthrough", no_argument, NULL, '3' }, { "rtp-input", required_argument, NULL, 'D' }, { "asi-adapter", required_argument, NULL, 'A' }, { "any-type", no_argument, NULL, 'z' }, { "dvb-compliance", no_argument, NULL, 'C' }, { "emm-passthrough", no_argument, NULL, 'W' }, { "ecm-passthrough", no_argument, NULL, 'Y' }, { "epg-passthrough", no_argument, NULL, 'e' }, { "network-name", no_argument, NULL, 'M' }, { "network-id", no_argument, NULL, 'N' }, { "system-charset", required_argument, NULL, 'j' }, { "dvb-charset", required_argument, NULL, 'J' }, { "provider-name", required_argument, NULL, 'B' }, { "logger", no_argument, NULL, 'l' }, { "logger-ident", required_argument, NULL, 'g' }, { "print", required_argument, NULL, 'x' }, { "quit-timeout", required_argument, NULL, 'Q' }, { "print-period", required_argument, NULL, '6' }, { "es-timeout", required_argument, NULL, '7' }, { "quiet", no_argument, NULL, 'q' }, { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, { "mrtg-file", required_argument, NULL, 'Z' }, { "ca-number", required_argument, NULL, 'y' }, { "pidmap", required_argument, NULL, '0' }, { "dvr-buf-size", required_argument, NULL, '2' }, { 0, 0, 0, 0 } }; while ( (c = getopt_long(i_argc, pp_argv, "q::c:r:t:o:i:a:n:5:f:F:R:s:S:k:v:pb:I:m:P:K:G:H:X:O:uwUTL:E:d:3D:A:lg:zCWYeM:N:j:J:B:x:Q:6:7:hVZ:y:0:1:2:9:", long_options, NULL)) != -1 ) { switch ( c ) { case 'q': if ( optarg ) { if ( *optarg == 'q' ) /* e.g. -qqq */ { i_verbose--; while ( *optarg == 'q' ) { i_verbose--; optarg++; } } else { i_verbose -= atoi( optarg ); /* e.g. -q2 */ } } else { i_verbose--; /* -q */ } break; case 'c': psz_conf_file = optarg; /* * When configuration file is used it is reasonable to assume that * services may be added/removed. If b_select_pmts is not set dvblast * is unable to start streaming newly added services in the config. */ b_select_pmts = 1; break; case 'r': psz_srv_socket = optarg; break; case 't': i_ttl_global = strtol( optarg, NULL, 0 ); break; case 'o': { struct in_addr maddr; if ( !inet_aton( optarg, &maddr ) ) usage(); memcpy( pi_ssrc_global, &maddr.s_addr, 4 * sizeof(uint8_t) ); break; } case 'i': i_priority = strtol( optarg, NULL, 0 ); break; case 'a': i_adapter = strtol( optarg, NULL, 0 ); break; case 'n': i_fenum = strtol( optarg, NULL, 0 ); break; case 'y': i_canum = strtol( optarg, NULL, 0 ); break; case '5': psz_delsys = optarg; break; case '9': dvb_plp_id = strtol( optarg, NULL, 0 ); break; case 'f': if (optarg && optarg[0] != '-') i_frequency = strtol( optarg, NULL, 0 ); if ( pf_Open != NULL ) usage(); #ifdef HAVE_DVB_SUPPORT pf_Open = dvb_Open; pf_Reset = dvb_Reset; pf_SetFilter = dvb_SetFilter; pf_UnsetFilter = dvb_UnsetFilter; #else msg_Err( NULL, "DVBlast is compiled without DVB support."); exit(1); #endif break; case 'F': i_fec = strtol( optarg, NULL, 0 ); break; case 'R': i_rolloff = strtol( optarg, NULL, 0 ); break; case 's': i_srate = strtol( optarg, NULL, 0 ); break; case 'S': i_satnum = strtol( optarg, NULL, 16 ); break; case 'k': i_uncommitted = strtol( optarg, NULL, 16 ); break; case 'v': i_voltage = strtol( optarg, NULL, 0 ); break; case 'p': b_tone = 1; break; case 'b': i_bandwidth = strtol( optarg, NULL, 0 ); break; case 'I': i_inversion = strtol( optarg, NULL, 0 ); break; case 'm': psz_modulation = optarg; break; case 'P': i_pilot = strtol( optarg, NULL, 0 ); break; case '1': i_mis = strtol( optarg, NULL, 0 ); break; case 'K': i_fec_lp = strtol( optarg, NULL, 0 ); break; case 'G': i_guard = strtol( optarg, NULL, 0 ); break; case 'X': i_transmission = strtol( optarg, NULL, 0 ); break; case 'O': i_frontend_timeout_duration = strtoll( optarg, NULL, 0 ) * 1000; break; case 'H': i_hierarchy = strtol( optarg, NULL, 0 ); break; case 'u': b_budget_mode = 1; break; case 'w': b_select_pmts = !b_select_pmts; break; case 'U': b_udp_global = true; break; case 'L': i_latency_global = strtoll( optarg, NULL, 0 ) * 1000; break; case 'E': i_retention_global = strtoll( optarg, NULL, 0 ) * 1000; break; case 'd': psz_dup_config = optarg; break; case '3': b_passthrough = true; print_fh = stderr; break; case 'D': psz_udp_src = optarg; if ( pf_Open != NULL ) usage(); pf_Open = udp_Open; pf_Reset = udp_Reset; pf_SetFilter = udp_SetFilter; pf_UnsetFilter = udp_UnsetFilter; break; case 'A': #ifdef HAVE_ASI_SUPPORT if ( pf_Open != NULL ) usage(); if ( strncmp(optarg, "deltacast:", 10) == 0) { #ifdef HAVE_ASI_DELTACAST_SUPPORT i_asi_adapter = strtol( optarg+10, NULL, 0 ); pf_Open = asi_deltacast_Open; pf_Reset = asi_deltacast_Reset; pf_SetFilter = asi_deltacast_SetFilter; pf_UnsetFilter = asi_deltacast_UnsetFilter; #else msg_Err( NULL, "DVBlast is compiled without Deltacast ASI support."); exit(1); #endif } else { i_asi_adapter = strtol( optarg, NULL, 0 ); pf_Open = asi_Open; pf_Reset = asi_Reset; pf_SetFilter = asi_SetFilter; pf_UnsetFilter = asi_UnsetFilter; } #else msg_Err( NULL, "DVBlast is compiled without ASI support."); exit(1); #endif break; case 'z': b_any_type = 1; break; case 'C': b_dvb_global = true; break; case 'W': b_enable_emm = true; break; case 'Y': b_enable_ecm = true; break; case 'e': b_epg_global = true; break; case 'M': psz_network_name = optarg; break; case 'N': i_network_id = strtoul( optarg, NULL, 0 ); break; case 'T': b_random_tsid = 1; break; case 'j': psz_native_charset = optarg; break; case 'J': psz_dvb_charset = optarg; break; case 'B': psz_provider_name = optarg; break; case 'l': b_enable_syslog = 1; break; case 'g': psz_syslog_ident = optarg; break; case 'x': b_print_enabled = true; if ( !strcmp(optarg, "text") ) i_print_type = PRINT_TEXT; else if ( !strcmp(optarg, "xml") ) i_print_type = PRINT_XML; else { b_print_enabled = false; msg_Warn( NULL, "unrecognized print type %s", optarg ); } break; case 'Q': i_quit_timeout_duration = strtoll( optarg, NULL, 0 ) * 1000; break; case '6': i_print_period = strtoll( optarg, NULL, 0 ) * 1000; break; case '7': i_es_timeout = strtoll( optarg, NULL, 0 ) * 1000; break; case 'V': DisplayVersion(); exit(0); break; case 'Z': psz_mrtg_file = optarg; break; case '0': { /* We expect a comma separated list of numbers. Put them into the pi_newpids array as they appear */ char *str1; char *saveptr = NULL; char *tok = NULL; int i, i_newpid; for (i = 0, str1 = optarg; i < N_MAP_PIDS; i++, str1 = NULL) { tok = strtok_r(str1, ",", &saveptr); if ( !tok ) break; i_newpid = strtoul(tok, NULL, 0); if ( !i_newpid ) { msg_Err( NULL, "Invalid pidmap string" ); usage(); } pi_newpids[i] = i_newpid; } b_do_remap = true; break; } #ifdef HAVE_DVB_SUPPORT case '2': i_dvr_buffer_size = strtol( optarg, NULL, 0 ); if (!i_dvr_buffer_size) usage(); // it exits /* roundup to packet size */ i_dvr_buffer_size += TS_SIZE - 1; i_dvr_buffer_size /= TS_SIZE; i_dvr_buffer_size *= TS_SIZE; break; #endif case 'h': default: usage(); } } if ( optind < i_argc || pf_Open == NULL ) usage(); if ( b_enable_syslog ) msg_Connect( psz_syslog_ident ? psz_syslog_ident : pp_argv[0] ); if ( b_print_enabled ) { /* Make std* line-buffered */ setvbuf(print_fh, NULL, _IOLBF, 0); } if ( i_verbose ) DisplayVersion(); msg_Warn( NULL, "restarting" ); switch (i_print_type) { case PRINT_XML: fprintf(print_fh, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); fprintf(print_fh, "<TS>\n"); break; default: break; } if ( b_udp_global ) { msg_Warn( NULL, "raw UDP output is deprecated. Please consider using RTP." ); msg_Warn( NULL, "for DVB-IP compliance you should use RTP." ); } if ( b_epg_global && !b_dvb_global ) { msg_Dbg( NULL, "turning on DVB compliance, required by EPG information" ); b_dvb_global = true; } if ((event_loop = ev_default_loop(0)) == NULL) { msg_Err( NULL, "unable to initialize libev" ); exit(EXIT_FAILURE); } memset( &output_dup, 0, sizeof(output_dup) ); if ( psz_dup_config != NULL ) { output_config_t config; config_Defaults( &config ); if ( !config_ParseHost( &config, psz_dup_config ) ) msg_Err( NULL, "Invalid target address for -d switch" ); else { output_Init( &output_dup, &config ); output_Change( &output_dup, &config ); } config_Free( &config ); } config_strdvb( &network_name, psz_network_name ); config_strdvb( &provider_name, psz_provider_name ); /* Set signal handlers */ signal_watcher_init(&sigint_watcher, event_loop, sighandler, SIGINT); signal_watcher_init(&sigterm_watcher, event_loop, sighandler, SIGTERM); signal_watcher_init(&sighup_watcher, event_loop, sighandler, SIGHUP); srand( time(NULL) * getpid() ); demux_Open(); // init the mrtg logfile mrtgInit(psz_mrtg_file); if ( i_priority > 0 ) { memset( ¶m, 0, sizeof(struct sched_param) ); param.sched_priority = i_priority; if ( (i_error = pthread_setschedparam( pthread_self(), SCHED_RR, ¶m )) ) { msg_Warn( NULL, "couldn't set thread priority: %s", strerror(i_error) ); } } config_ReadFile(); if ( psz_srv_socket != NULL ) comm_Open(); if ( i_quit_timeout_duration ) { ev_timer_init(&quit_watcher, quit_cb, i_quit_timeout_duration / 1000000., 0); ev_timer_start(event_loop, &quit_watcher); } outputs_Init(); ev_run(event_loop, 0); mrtgClose(); outputs_Close( i_nb_outputs ); demux_Close(); dvb_string_clean( &network_name ); dvb_string_clean( &provider_name ); if ( conf_iconv != (iconv_t)-1 ) iconv_close( conf_iconv ); switch (i_print_type) { case PRINT_XML: fprintf(print_fh, "</TS>\n"); break; default: break; } if ( b_enable_syslog ) msg_Disconnect(); comm_Close(); block_Vacuum(); return EXIT_SUCCESS; }
Options::Options (int argc, char** argv) :iVersion (false), iHelpFlag (false), iPkgUIDSpecified (false), iRegistryEntrySpecified (false) { int argCount = argc; const char* buffer = getenv("DUMPSWIREGISTRY"); if(buffer) { string regPath(buffer); iRegistryFilePath = regPath; } ++argv; //check whether the first argument is a registry path if((**argv != '-') && (**argv != '/')) { iRegistryFilePath = *argv; ++argv; --argc; } if(*argv != NULL) { if ((**argv != '-') && (**argv != '/')) { throw EInvalidOption; } switch ((*argv)[1]) { case 'h': case 'H': case '?': { iHelpFlag = true; DisplayUsage(); break; } case 'v': case 'V': { iVersion = true; DisplayVersion(); break; } case 'p': case 'P': { iPkgUIDSpecified = true; if(iRegistryFilePath.length() == 0) { throw ESetEnvironmentVariable; } if(argc !=3) { throw EInvalidOption; } iPkgUID = *++argv; break; } case 'r': case 'R': { iRegistryEntrySpecified = true; if(iRegistryFilePath.length() == 0) { throw ESetEnvironmentVariable; } if(argc != 5) { throw EInvalidOption; } iPkgUID = *++argv; iPkgName = *++argv; iVendorName = *++argv; break; } default: { throw EInvalidOption; } } } else { throw EInvalidOption; } CheckCmdLineExceptions(); }