bool CClientApp::parseArg(const int& argc, const char* const* argv, int& i) { if (CApp::parseArg(argc, argv, i)) { // found common arg return true; } else if (isArg(i, argc, argv, NULL, "--camp")) { // ignore -- included for backwards compatibility } else if (isArg(i, argc, argv, NULL, "--no-camp")) { // ignore -- included for backwards compatibility } else if (isArg(i, argc, argv, NULL, "--yscroll", 1)) { // define scroll args().m_yscroll = atoi(argv[++i]); } else { // option not supported here return false; } // argument was valid return true; }
bool CArgParser::parseServerArgs(CServerArgs& args, int argc, const char* const* argv) { setArgsBase(args); updateCommonArgs(argv); for (int i = 1; i < argc; ++i) { if (parsePlatformArg(args, argc, argv, i)) { continue; } else if (parseGenericArgs(argc, argv, i)) { continue; } else if (isArg(i, argc, argv, "-a", "--address", 1)) { // save listen address args.m_synergyAddress = argv[++i]; } else if (isArg(i, argc, argv, "-c", "--config", 1)) { // save configuration file path args.m_configFile = argv[++i]; } else { LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname)); return false; } } if (checkUnexpectedArgs()) { return false; } return true; }
bool ArgParser::parseToolArgs(ToolArgs& args, int argc, const char* const* argv) { for (int i = 1; i < argc; ++i) { if (isArg(i, argc, argv, NULL, "--get-active-desktop", 0)) { args.m_printActiveDesktopName = true; return true; } else if (isArg(i, argc, argv, NULL, "--login-auth", 0)) { args.m_loginAuthenticate = true; return true; } else if (isArg(i, argc, argv, NULL, "--get-plugin-list", 0)) { args.m_getPluginList = true; return true; } else if (isArg(i, argc, argv, NULL, "--get-installed-dir", 0)) { args.m_getInstalledDir = true; return true; } else if (isArg(i, argc, argv, NULL, "--get-plugin-dir", 0)) { args.m_getPluginDir = true; return true; } else if (isArg(i, argc, argv, NULL, "--get-profile-dir", 0)) { args.m_getProfileDir = true; return true; } else if (isArg(i, argc, argv, NULL, "--get-arch", 0)) { args.m_getArch = true; return true; } else if (isArg(i, argc, argv, NULL, "--subscription-serial", 1)) { args.m_subscriptionSerial = argv[++i]; if (args.m_subscriptionSerial.empty()) { LOG((CLOG_CRIT "subscription error: serial was not provided")); return false; } return true; } else if (isArg(i, argc, argv, NULL, "--get-subscription-filename", 0)) { args.m_getSubscriptionFilename = true; return true; } else if (isArg(i, argc, argv, NULL, "--check-subscription", 0)) { args.m_checkSubscription = true; return true; } else { return false; } } return false; }
bool ArgParser::parseClientArgs(ClientArgs& args, int argc, const char* const* argv) { setArgsBase(args); updateCommonArgs(argv); int i; for (i = 1; i < argc; ++i) { if (parsePlatformArg(args, argc, argv, i)) { continue; } else if (parseGenericArgs(argc, argv, i)) { continue; } else if (parseDeprecatedArgs(argc, argv, i)) { continue; } else if (isArg(i, argc, argv, NULL, "--camp")) { // ignore -- included for backwards compatibility } else if (isArg(i, argc, argv, NULL, "--no-camp")) { // ignore -- included for backwards compatibility } else if (isArg(i, argc, argv, NULL, "--yscroll", 1)) { // define scroll args.m_yscroll = atoi(argv[++i]); } else { if (i + 1 == argc) { args.m_synergyAddress = argv[i]; return true; } LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname)); return false; } } // exactly one non-option argument (server-address) if (i == argc) { LOG((CLOG_PRINT "%s: a server address or name is required" BYE, args.m_pname, args.m_pname)); return false; } if (checkUnexpectedArgs()) { return false; } return true; }
int main(int argc , char* argv[]) { if (argc == 1) { printUsage (&cout , argv [0]); return 0; } Cat MyCat (argc , argv); int nPos = isArg (argc , argv); ostream* Out = NULL; ofstream OutFile; if (nPos != -1) { string Path = getFile (argv [nPos]); OutFile.open (Path.c_str () , ios::app); Out = &OutFile; } else { Out = &cout; } MyCat.print (Out); if (nPos != -1) { OutFile.close (); } return 0; }
void CApp::parseArgs(int argc, const char* const* argv, int& i) { // about these use of assert() here: // previously an /analyze warning was displayed if we only used assert and // did not return on failure. however, this warning does not appear to show // any more (could be because new compiler args have been added). // the asserts are programmer benefit only; the os should never pass 0 args, // because the first is always the binary name. the only way assert would // evaluate to true, is if this parse function were implemented incorrectly, // which is unlikely because it's old code and has a specific use. // we should avoid using anything other than assert here, because it will // look like important code, which it's not really. assert(argsBase().m_pname != NULL); assert(argv != NULL); assert(argc >= 1); // set defaults argsBase().m_name = ARCH->getHostName(); LOG((CLOG_INFO "CApp::parseArgs call")); // parse options for (i = 1; i < argc; ++i) { if (parseArg(argc, argv, i)) { continue; } else if (isArg(i, argc, argv, "--", NULL)) { // remaining arguments are not options ++i; break; } else if (argv[i][0] == '-') { std::cerr << "Unrecognized option: " << argv[i] << std::endl; m_bye(kExitArgs); } else { // this and remaining arguments are not options break; } } #if SYSAPI_WIN32 // suggest that user installs as a windows service. when launched as // service, process should automatically detect that it should run in // daemon mode. if (argsBase().m_daemon) { LOG((CLOG_ERR "The --daemon argument is not supported on Windows. " "Instead, install %s as a service (--service install).", argsBase().m_pname)); m_bye(kExitArgs); } #endif }
bool ArgParser::parseDeprecatedArgs(int argc, const char* const* argv, int& i) { if (isArg(i, argc, argv, NULL, "--crypto-pass")) { LOG((CLOG_NOTE "--crypto-pass is deprecated")); i++; return true; } return false; }
bool CArgParser::parsePlatformArg(CArgsBase& argsBase, const int& argc, const char* const* argv, int& i) { #if WINAPI_MSWINDOWS if (isArg(i, argc, argv, NULL, "--service")) { LOG((CLOG_WARN "obsolete argument --service, use synergyd instead.")); argsBase.m_shouldExit = true; } else if (isArg(i, argc, argv, NULL, "--exit-pause")) { argsBase.m_pauseOnExit = true; } else if (isArg(i, argc, argv, NULL, "--stop-on-desk-switch")) { argsBase.m_stopOnDeskSwitch = true; } else { // option not supported here return false; } return true; #elif WINAPI_XWINDOWS if (isArg(i, argc, argv, "-display", "--display", 1)) { // use alternative display argsBase.m_display = argv[++i]; } else if (isArg(i, argc, argv, NULL, "--no-xinitthreads")) { argsBase.m_disableXInitThreads = true; } else { // option not supported here return false; } return true; #elif WINAPI_CARBON // no options for carbon return false; #endif }
bool CServerApp::parseArg(const int& argc, const char* const* argv, int& i) { if (CApp::parseArg(argc, argv, i)) { // found common arg return true; } else if (isArg(i, argc, argv, "-a", "--address", 1)) { // save listen address try { *args().m_synergyAddress = CNetworkAddress(argv[i + 1], kDefaultPort); args().m_synergyAddress->resolve(); } catch (XSocketAddress& e) { LOG((CLOG_PRINT "%s: %s" BYE, args().m_pname, e.what(), args().m_pname)); m_bye(kExitArgs); } ++i; } else if (isArg(i, argc, argv, "-c", "--config", 1)) { // save configuration file path args().m_configFile = argv[++i]; } else { // option not supported here return false; } // argument was valid return true; }
bool CArgParser::parseToolArgs(CToolArgs& args, int argc, const char* const* argv) { for (int i = 1; i < argc; ++i) { if (isArg(i, argc, argv, NULL, "--get-active-desktop", 0)) { args.m_printActiveDesktopName = true; return true; } else { return false; } } return false; }
static bool ProcessServiceModes(range<const wchar_t* const*> const Args, int& ServiceResult) { const auto& isArg = [](const wchar_t* Arg, string_view const Name) { return (*Arg == L'/' || *Arg == L'-') && equal_icase(Arg + 1, Name); }; if (Args.size() == 4 && IsElevationArgument(Args[0])) // /service:elevation {GUID} PID UsePrivileges { ServiceResult = ElevationMain(Args[1], std::wcstoul(Args[2], nullptr, 10), *Args[3] == L'1'); return true; } if (InRange(2u, Args.size(), 5u) && (isArg(Args[0], L"export"sv) || isArg(Args[0], L"import"sv))) { const auto Export = isArg(Args[0], L"export"sv); string strProfilePath(Args.size() > 2 ? Args[2] : L""), strLocalProfilePath(Args.size() > 3 ? Args[3] : L""), strTemplatePath(Args.size() > 4 ? Args[4] : L""); InitTemplateProfile(strTemplatePath); InitProfile(strProfilePath, strLocalProfilePath); Global->m_ConfigProvider = new config_provider(Export? config_provider::mode::m_export : config_provider::mode::m_import); ServiceResult = !ConfigProvider().ServiceMode(Args[1]); return true; } if (InRange(1u, Args.size(), 3u) && isArg(Args[0], L"clearcache"sv)) { string strProfilePath(Args.size() > 1 ? Args[1] : L""); string strLocalProfilePath(Args.size() > 2 ? Args[2] : L""); InitProfile(strProfilePath, strLocalProfilePath); config_provider::ClearPluginsCache(); ServiceResult = 0; return true; } return false; }
void CGameApplication::mainLoop() { /* // Définition de la langue de l'application if (isArg("--lang")) { CString lang = getArg(getArgPosition("--lang") + 1); setLanguage(TLang::French); ... } */ // Chargement d'une map au démarrage if (isArg("--map")) { CString map_name = getArg(getArgPosition("--map") + 1); loadMap(map_name); } /* // Lancement en mode serveur if (isArg ("--server")) { //... } */ #ifdef T_ACTIVE_DEBUG_MODE m_activityDebug = new CActivity("debug"); CWindowDebug * windowDebug = new CWindowDebug(); m_activityDebug->addWindow(windowDebug); windowDebug->open(); windowDebug->setFocus(); #endif // T_ACTIVE_DEBUG_MODE // Boucle de l'application while (eventLoop()); closeGame(); }
int main(int argc, char **argv) { char action[12]=""; if(isArg(argc, argv, "-writeall")) { strcpy(action, "-writeall"); }; infolog_SetFacility((char *)"CTP"); infolog_SetStream("",0); setlinebuf(stdout); signal(SIGUSR1, gotsignal); siginterrupt(SIGUSR1, 0); signal(SIGQUIT, gotsignal); siginterrupt(SIGQUIT, 0); signal(SIGBUS, gotsignal); siginterrupt(SIGBUS, 0); micrate(-1); if(micratepresent()) { SLOT_S= 30; // was 60 before 10.11.2011 } else { SLOT_S= 5; // in lab just 5secs }; /* if(envcmp("VMESITE", "ALICE")==0) { udpsock= udpopens("alidcscom835", send2PORT); } else { udpsock= udpopens("adls", send2PORT); }; */ ds_register(action); while(1) { int rc=0; rc= update_qpll(); if(rc!=0) break; //printf("sleteping 10secs...\n"); fflush(stdout); //sleep(1) ; //msleep(1000); dtq_sleep(2); //printf("slept 10secs...\n"); fflush(stdout); }; ds_stop(); exit(0); }
bool CApp::parseArg(const int& argc, const char* const* argv, int& i) { if (ARCH->parseArg(argc, argv, i)) { // handled by platform util return true; } else if (isArg(i, argc, argv, "-d", "--debug", 1)) { // change logging level argsBase().m_logFilter = argv[++i]; } else if (isArg(i, argc, argv, "-l", "--log", 1)) { argsBase().m_logFile = argv[++i]; } else if (isArg(i, argc, argv, "-f", "--no-daemon")) { // not a daemon argsBase().m_daemon = false; } else if (isArg(i, argc, argv, NULL, "--daemon")) { // daemonize argsBase().m_daemon = true; } else if (isArg(i, argc, argv, "-n", "--name", 1)) { // save screen name argsBase().m_name = argv[++i]; } else if (isArg(i, argc, argv, "-1", "--no-restart")) { // don't try to restart argsBase().m_restartable = false; } else if (isArg(i, argc, argv, NULL, "--restart")) { // try to restart argsBase().m_restartable = true; } else if (isArg(i, argc, argv, "-z", NULL)) { argsBase().m_backend = true; } else if (isArg(i, argc, argv, NULL, "--no-hooks")) { argsBase().m_noHooks = true; } else if (isArg(i, argc, argv, "-h", "--help")) { help(); m_bye(kExitSuccess); } else if (isArg(i, argc, argv, NULL, "--version")) { version(); m_bye(kExitSuccess); } else if (isArg(i, argc, argv, NULL, "--no-tray")) { argsBase().m_disableTray = true; } else { // option not supported here return false; } return true; }
static void parse(int argc, const char* const* argv) { assert(ARG->m_pname != NULL); assert(argv != NULL); assert(argc >= 1); // set defaults ARG->m_name = ARCH->getHostName(); // parse options int i; for (i = 1; i < argc; ++i) { if (isArg(i, argc, argv, "-d", "--debug", 1)) { // change logging level ARG->m_logFilter = argv[++i]; } else if (isArg(i, argc, argv, "-n", "--name", 1)) { // save screen name ARG->m_name = argv[++i]; } else if (isArg(i, argc, argv, NULL, "--camp")) { // ignore -- included for backwards compatibility } else if (isArg(i, argc, argv, NULL, "--no-camp")) { // ignore -- included for backwards compatibility } else if (isArg(i, argc, argv, "-f", "--no-daemon")) { // not a daemon ARG->m_daemon = false; } else if (isArg(i, argc, argv, NULL, "--daemon")) { // daemonize ARG->m_daemon = true; } else if (isArg(i, argc, argv, "-1", "--no-restart")) { // don't try to restart ARG->m_restartable = false; } else if (isArg(i, argc, argv, NULL, "--restart")) { // try to restart ARG->m_restartable = true; } else if (isArg(i, argc, argv, "-z", NULL)) { ARG->m_backend = true; } else if (isArg(i, argc, argv, "-h", "--help")) { help(); bye(kExitSuccess); } else if (isArg(i, argc, argv, NULL, "--version")) { version(); bye(kExitSuccess); } else if (isArg(i, argc, argv, "--", NULL)) { // remaining arguments are not options ++i; break; } else if (argv[i][0] == '-') { LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, ARG->m_pname, argv[i], ARG->m_pname)); bye(kExitArgs); } else { // this and remaining arguments are not options break; } } // exactly one non-option argument (server-address) if (i == argc) { LOG((CLOG_PRINT "%s: a server address or name is required" BYE, ARG->m_pname, ARG->m_pname)); bye(kExitArgs); } if (i + 1 != argc) { LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, ARG->m_pname, argv[i], ARG->m_pname)); bye(kExitArgs); } // save server address try { ARG->m_serverAddress = CNetworkAddress(argv[i], kDefaultPort); } catch (XSocketAddress& e) { LOG((CLOG_PRINT "%s: %s" BYE, ARG->m_pname, e.what(), ARG->m_pname)); bye(kExitFailed); } // increase default filter level for daemon. the user must // explicitly request another level for a daemon. if (ARG->m_daemon && ARG->m_logFilter == NULL) { #if WINDOWS_LIKE if (CArchMiscWindows::isWindows95Family()) { // windows 95 has no place for logging so avoid showing // the log console window. ARG->m_logFilter = "FATAL"; } else #endif { ARG->m_logFilter = "NOTE"; } } // set log filter if (!CLOG->setFilter(ARG->m_logFilter)) { LOG((CLOG_PRINT "%s: unrecognized log level `%s'" BYE, ARG->m_pname, ARG->m_logFilter, ARG->m_pname)); bye(kExitArgs); } }
static void parse(int argc, const char* const* argv) { assert(ARG->m_pname != NULL); assert(argv != NULL); assert(argc >= 1); // set defaults ARG->m_name = ARCH->getHostName(); // parse options int i = 1; for (; i < argc; ++i) { if (isArg(i, argc, argv, "-d", "--debug", 1)) { // change logging level ARG->m_logFilter = argv[++i]; } else if (isArg(i, argc, argv, "-a", "--address", 1)) { // save listen address try { *ARG->m_synergyAddress = CNetworkAddress(argv[i + 1], kDefaultPort); ARG->m_synergyAddress->resolve(); } catch (XSocketAddress& e) { LOG((CLOG_PRINT "%s: %s" BYE, ARG->m_pname, e.what(), ARG->m_pname)); bye(kExitArgs); } ++i; } else if (isArg(i, argc, argv, "-n", "--name", 1)) { // save screen name ARG->m_name = argv[++i]; } else if (isArg(i, argc, argv, "-c", "--config", 1)) { // save configuration file path ARG->m_configFile = argv[++i]; } #if WINAPI_XWINDOWS else if (isArg(i, argc, argv, "-display", "--display", 1)) { // use alternative display ARG->m_display = argv[++i]; } #endif else if (isArg(i, argc, argv, "-f", "--no-daemon")) { // not a daemon ARG->m_daemon = false; } else if (isArg(i, argc, argv, NULL, "--daemon")) { // daemonize ARG->m_daemon = true; } else if (isArg(i, argc, argv, "-1", "--no-restart")) { // don't try to restart ARG->m_restartable = false; } else if (isArg(i, argc, argv, NULL, "--restart")) { // try to restart ARG->m_restartable = true; } else if (isArg(i, argc, argv, "-z", NULL)) { ARG->m_backend = true; } else if (isArg(i, argc, argv, "-h", "--help")) { help(); bye(kExitSuccess); } else if (isArg(i, argc, argv, NULL, "--version")) { version(); bye(kExitSuccess); } else if (isArg(i, argc, argv, "--", NULL)) { // remaining arguments are not options ++i; break; } else if (argv[i][0] == '-') { LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, ARG->m_pname, argv[i], ARG->m_pname)); bye(kExitArgs); } else { // this and remaining arguments are not options break; } } // no non-option arguments are allowed if (i != argc) { LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, ARG->m_pname, argv[i], ARG->m_pname)); bye(kExitArgs); } // increase default filter level for daemon. the user must // explicitly request another level for a daemon. if (ARG->m_daemon && ARG->m_logFilter == NULL) { #if SYSAPI_WIN32 if (CArchMiscWindows::isWindows95Family()) { // windows 95 has no place for logging so avoid showing // the log console window. ARG->m_logFilter = "FATAL"; } else #endif { ARG->m_logFilter = "NOTE"; } } // set log filter if (!CLOG->setFilter(ARG->m_logFilter)) { LOG((CLOG_PRINT "%s: unrecognized log level `%s'" BYE, ARG->m_pname, ARG->m_logFilter, ARG->m_pname)); bye(kExitArgs); } // identify system LOG((CLOG_INFO "Synergy server %s on %s", kVersion, ARCH->getOSName().c_str())); }
/*----------------------------------------*/ int main(int argc, char **argv) { int rc; int ssmcr_tries=0; infolog_SetFacility("CTP"); infolog_SetStream("",0); #ifdef PQWAY printf("main_ctp: opening rec/send queues...\n"); mq_rec= pq_open(); if(mq_rec==(mqd_t)-1) { infolog_trgboth(LOG_FATAL, "posix mq_rec not created"); exit(8); } mq_sendmsg= pq_connect(); if(mq_sendmsg==(mqd_t)-1) { infolog_trgboth(LOG_FATAL, "posix mq_sendmsg not connected"); exit(8); } #endif signal(SIGUSR1, gotsignal); siginterrupt(SIGUSR1, 0); signal(SIGQUIT, gotsignal); siginterrupt(SIGQUIT, 0); signal(SIGKILL, gotsignal); siginterrupt(SIGKILL, 0); // -9 signal(SIGTERM, gotsignal); siginterrupt(SIGTERM, 0); // kill pid signal(SIGINT, gotsignal); siginterrupt(SIGINT, 0); // CTRL C 2 partmode[0]='\0'; printf("cshmInit i.e. initBakery(swtriggers/ccread/ssmcr ONLY once, when shm allocated)...\n"); /*printf("initBakery(swtriggers,4): 0:SOD/EOD 1:gcalib 2:ctp.exe 3:dims\n"); printf("initBakery(ccread,5): 0:proxy 1:dims 2:ctp+busytool 3:smaq 4:inputs\n"); */ cshmInit(); setglobalflags(argc, argv); /* changed in aug2016 (initBakery only once from now, when shm allocated) printf("initBakery(swtriggers,4): 0:SOD/EOD 1:gcalib 2:ctp.exe 3:dims\n"); initBakery(&ctpshmbase->swtriggers, "swtriggers", swtriggers_N); printf("initBakery(ccread,6): 0:proxy 1:dims 2:ctp+busytool 3:smaq 4:inputs 5:orbitddl2\n"); initBakery(&ctpshmbase->ccread, "ccread", ccread_N); printf("initBakery(ssmcr,4): 0:smaq 1:orbitddl2 2:ctp 3:inputs\n"); initBakery(&ctpshmbase->ssmcr, "ssmcr", ssmcr_N); */ printBakery(&ctpshmbase->swtriggers); printBakery(&ctpshmbase->ccread); printBakery(&ctpshmbase->ssmcr); unlockBakery(&ctpshmbase->swtriggers,swtriggers_ctpproxy); unlockBakery(&ctpshmbase->ccread,ccread_ctpproxy); unlockBakery(&ctpshmbase->ssmcr,ssmcr_ctpproxy); /* Let' synchronise with smcr only, i.e. - ccread_dims,... can go in parallel with ctp_Initproxy, orbitddl2: should use ccread_orbitddl2 customer when reading counters - swtriggers_gcalib/_dims cannot appear (no global runs becasue ctpproxy being restarted) */ while(1) { // do not allow SSM usage (smaq) because ctp_Initproxy is initialising it char msg[100]; rc= lockBakeryTimeout(&ctpshmbase->ssmcr,ssmcr_ctpproxy, 10); if(rc==1) { if(ssmcr_tries>0) { sprintf(msg, "Got ssmcr resource after %d attempts", ssmcr_tries); infolog_trgboth(LOG_INFO, msg); }; break; // ssmcr reserved for me now }; ssmcr_tries++; sprintf(msg,"%d secs Waiting for ssmcr resource. Is smaq stopped?", ssmcr_tries*10); infolog_trgboth(LOG_WARNING, msg); }; if(isArg(argc, argv, "configrunset")) { /* do we need before orbitddl2.py INT/L2 orbit in SYNC (automatic with L2a)? */ int rc, reslen; char cmd[200]; char result[1000]=""; // ~ 10 lines char orbchanged[]="Warning: orbitoffset changed:"; if(envcmp("VMESITE", "PRIVATE")==0) { strcpy(cmd, "who"); } else { strcpy(cmd, "orbitddl2.py configrunset"); }; infolog_trgboth(LOG_INFO, "Starting L0 orbit calibration (30s...)"); rc= popenread(cmd, result, 1000); // opens vme... reslen= strlen(result); if((rc==EXIT_FAILURE) || (reslen<=1)) { infolog_trgboth(LOG_ERROR, "L0 orbit calibration problem"); } else { int ixr= reslen; if(result[ixr-1]=='\n') { //remove last NL character if present result[ixr-1]='\0'; ixr= reslen-2; } else { ixr= reslen-1; // pointer to the last non-NEWLINE character }; while(ixr>=0) { // find last line if(result[ixr]=='\n') { ixr++; break; }; ixr--; }; sprintf(cmd, "L0 orbit calibration: %s", &result[ixr]); if((strcmp(&result[ixr], "Everything ok")==0) || (strncmp(&result[ixr], orbchanged, strlen(orbchanged))==0) ) { infolog_trgboth(LOG_INFO, cmd); } else { infolog_trgboth(LOG_ERROR, cmd); infolog_trgboth(LOG_ERROR, "ctpproxy not started"); unlockBakery(&ctpshmbase->ssmcr,ssmcr_ctpproxy); rc=8; goto STP; }; }; }; // init CTP after calibration (e.g. to repair modifications done by orbitddl2.py) rc=ctp_Initproxy(); unlockBakery(&ctpshmbase->ssmcr,ssmcr_ctpproxy); if(rc!=0) goto STP; // DIM services not registered here (see ctpdims.c), they run in separae task: // ds_register(); strcpy(obj,argv[1]); smi_attach(obj, SMI_handle_command); printf("CTP attached to: %s\n",obj); /* if smi_volatile: stops the ctp_proxy in case TRIGGER domain is down smi_volatile(); */ strcpy(errorReason,"not set"); smi_set_parER(); strcpy(ORBIT_NUMBER,""); smi_set_par("ORBIT_NUMBER",ORBIT_NUMBER,STRING); smi_setState("RUNNING"); while(1) { #ifdef PQWAY executectp("wait"); #else usleep(1000000); #endif if(quit>9) break; }; rc= ctp_Endproxy(); STP: #ifdef PQWAY pq_close(mq_sendmsg, 0); pq_close(mq_rec, 1); #endif printf("Calling cshmDetach()...\n"); cshmDetach(); return (rc); }
bool CArgParser::parseGenericArgs(int argc, const char* const* argv, int& i) { if (isArg(i, argc, argv, "-d", "--debug", 1)) { // change logging level argsBase().m_logFilter = argv[++i]; } else if (isArg(i, argc, argv, "-l", "--log", 1)) { argsBase().m_logFile = argv[++i]; } else if (isArg(i, argc, argv, "-f", "--no-daemon")) { // not a daemon argsBase().m_daemon = false; } else if (isArg(i, argc, argv, NULL, "--daemon")) { // daemonize argsBase().m_daemon = true; } else if (isArg(i, argc, argv, "-n", "--name", 1)) { // save screen name argsBase().m_name = argv[++i]; } else if (isArg(i, argc, argv, "-1", "--no-restart")) { // don't try to restart argsBase().m_restartable = false; } else if (isArg(i, argc, argv, NULL, "--restart")) { // try to restart argsBase().m_restartable = true; } else if (isArg(i, argc, argv, "-z", NULL)) { argsBase().m_backend = true; } else if (isArg(i, argc, argv, NULL, "--no-hooks")) { argsBase().m_noHooks = true; } else if (isArg(i, argc, argv, "-h", "--help")) { if (m_app) { m_app->help(); } argsBase().m_shouldExit = true; } else if (isArg(i, argc, argv, NULL, "--version")) { if (m_app) { m_app->version(); } argsBase().m_shouldExit = true; } else if (isArg(i, argc, argv, NULL, "--no-tray")) { argsBase().m_disableTray = true; } else if (isArg(i, argc, argv, NULL, "--ipc")) { argsBase().m_enableIpc = true; } else if (isArg(i, argc, argv, NULL, "--server")) { // HACK: stop error happening when using portable (synergyp) } else if (isArg(i, argc, argv, NULL, "--client")) { // HACK: stop error happening when using portable (synergyp) } else if (isArg(i, argc, argv, NULL, "--crypto-pass")) { argsBase().m_crypto.m_pass = argv[++i]; argsBase().m_crypto.setMode("cfb"); } else if (isArg(i, argc, argv, NULL, "--enable-drag-drop")) { bool useDragDrop = true; #ifdef WINAPI_XWINDOWS useDragDrop = false; LOG((CLOG_INFO "ignoring --enable-drag-drop, not supported on linux.")); #endif #ifdef WINAPI_MSWINDOWS OSVERSIONINFO osvi; ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&osvi); if (osvi.dwMajorVersion < 6) { useDragDrop = false; LOG((CLOG_INFO "ignoring --enable-drag-drop, not supported below vista.")); } #endif if (useDragDrop) { argsBase().m_enableDragDrop = true; } } else { // option not supported here return false; } return true; }
static void parse(int argc, const char* const* argv) { assert(ARG->m_pname != NULL); assert(argv != NULL); assert(argc >= 1); if(ARG->m_pname == NULL || argv == NULL || argc < 1) { return; } // set defaults ARG->m_name = ARCH->getHostName(); // parse options int i; for (i = 1; i < argc; ++i) { if (isArg(i, argc, argv, "-d", "--debug", 1)) { // change logging level ARG->m_logFilter = argv[++i]; } else if (isArg(i, argc, argv, "-n", "--name", 1)) { // save screen name ARG->m_name = argv[++i]; } else if (isArg(i, argc, argv, NULL, "--camp")) { // ignore -- included for backwards compatibility } else if (isArg(i, argc, argv, NULL, "--no-camp")) { // ignore -- included for backwards compatibility } else if (isArg(i, argc, argv, "-f", "--no-daemon")) { // not a daemon ARG->m_daemon = false; } else if (isArg(i, argc, argv, NULL, "--daemon")) { // daemonize ARG->m_daemon = true; } #if WINAPI_XWINDOWS else if (isArg(i, argc, argv, "-display", "--display", 1)) { // use alternative display ARG->m_display = argv[++i]; } #endif else if (isArg(i, argc, argv, NULL, "--yscroll", 1)) { // define scroll ARG->m_yscroll = atoi(argv[++i]); } else if (isArg(i, argc, argv, "-l", "--log", 1)) { ARG->m_logFile = argv[++i]; } else if (isArg(i, argc, argv, "-1", "--no-restart")) { // don't try to restart ARG->m_restartable = false; } else if (isArg(i, argc, argv, NULL, "--restart")) { // try to restart ARG->m_restartable = true; } else if (isArg(i, argc, argv, "-z", NULL)) { ARG->m_backend = true; } else if (isArg(i, argc, argv, "-h", "--help")) { help(); bye(kExitSuccess); } else if (isArg(i, argc, argv, NULL, "--version")) { version(); bye(kExitSuccess); } else if (isArg(i, argc, argv, NULL, "--no-xinitthreads")) { ARG->m_disableXInitThreads = true; } else if (isArg(i, argc, argv, "--", NULL)) { // remaining arguments are not options ++i; break; } else if (argv[i][0] == '-') { LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, ARG->m_pname, argv[i], ARG->m_pname)); bye(kExitArgs); } else { // this and remaining arguments are not options break; } } // exactly one non-option argument (server-address) if (i == argc) { LOG((CLOG_PRINT "%s: a server address or name is required" BYE, ARG->m_pname, ARG->m_pname)); bye(kExitArgs); } if (i + 1 != argc) { LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, ARG->m_pname, argv[i], ARG->m_pname)); bye(kExitArgs); } // save server address try { *ARG->m_serverAddress = CNetworkAddress(argv[i], kDefaultPort); ARG->m_serverAddress->resolve(); } catch (XSocketAddress& e) { // allow an address that we can't look up if we're restartable. // we'll try to resolve the address each time we connect to the // server. a bad port will never get better. patch by Brent // Priddy. if (!ARG->m_restartable || e.getError() == XSocketAddress::kBadPort) { LOG((CLOG_PRINT "%s: %s" BYE, ARG->m_pname, e.what(), ARG->m_pname)); bye(kExitFailed); } } // increase default filter level for daemon. the user must // explicitly request another level for a daemon. if (ARG->m_daemon && ARG->m_logFilter == NULL) { #if SYSAPI_WIN32 if (CArchMiscWindows::isWindows95Family()) { // windows 95 has no place for logging so avoid showing // the log console window. ARG->m_logFilter = "FATAL"; } else #endif { ARG->m_logFilter = "NOTE"; } } // set log filter if (!CLOG->setFilter(ARG->m_logFilter)) { LOG((CLOG_PRINT "%s: unrecognized log level `%s'" BYE, ARG->m_pname, ARG->m_logFilter, ARG->m_pname)); bye(kExitArgs); } // identify system LOG((CLOG_INFO "%s Client on %s %s", kAppVersion, ARCH->getOSName().c_str(), ARCH->getPlatformName().c_str())); #ifdef WIN32 #ifdef _AMD64_ LOG((CLOG_WARN "This is an experimental x64 build of %s. Use it at your own risk.", kApplication)); #endif #endif }
std::string Game::argGetString(int index) { return isArg(index) ? m_args[index] : ""; }
int Game::argGetInt(int index) { return isArg(index) ? atoi(m_args[index].c_str()) : 0; }
bool CApp::parseArg(const int& argc, const char* const* argv, int& i) { LOG((CLOG_INFO "CApp::parseArg call")); LOG((CLOG_INFO "CARCH->parseArg(")); if (ARCH->parseArg(argc, argv, i)) { // handled by platform util return true; } else if (isArg(i,argc,argv, "-hw", "--helloworld",1)) { // custom common argument std::cout<<"custom argument: "<<argv[++i]<<"\n"; m_bye(kExitArgs); } else if (isArg(i, argc, argv, "-d", "--debug", 1)) { // change logging level argsBase().m_logFilter = argv[++i]; } else if (isArg(i, argc, argv, "-l", "--log", 1)) { argsBase().m_logFile = argv[++i]; } else if (isArg(i, argc, argv, "-f", "--no-daemon")) { // not a daemon argsBase().m_daemon = false; } else if (isArg(i, argc, argv, NULL, "--daemon")) { // daemonize argsBase().m_daemon = true; } else if (isArg(i, argc, argv, "-n", "--name", 1)) { // save screen name argsBase().m_name = argv[++i]; } else if (isArg(i, argc, argv, "-1", "--no-restart")) { // don't try to restart argsBase().m_restartable = false; } else if (isArg(i, argc, argv, NULL, "--restart")) { // try to restart argsBase().m_restartable = true; } else if (isArg(i, argc, argv, "-z", NULL)) { argsBase().m_backend = true; } else if (isArg(i, argc, argv, NULL, "--no-hooks")) { argsBase().m_noHooks = true; } else if (isArg(i, argc, argv, "-h", "--help")) { help(); m_bye(kExitSuccess); } else if (isArg(i, argc, argv, NULL, "--version")) { version(); m_bye(kExitSuccess); } else { // option not supported here return false; } return true; }
bool CApp::parseArg(const int& argc, const char* const* argv, int& i) { if (appUtil().parseArg(argc, argv, i)) { // handled by platform util return true; } else if (isArg(i, argc, argv, "-d", "--debug", 1)) { // change logging level argsBase().m_logFilter = argv[++i]; } else if (isArg(i, argc, argv, "-l", "--log", 1)) { argsBase().m_logFile = argv[++i]; } else if (isArg(i, argc, argv, "-f", "--no-daemon")) { // not a daemon argsBase().m_daemon = false; } else if (isArg(i, argc, argv, NULL, "--daemon")) { // daemonize argsBase().m_daemon = true; } else if (isArg(i, argc, argv, "-n", "--name", 1)) { // save screen name argsBase().m_name = argv[++i]; } else if (isArg(i, argc, argv, "-1", "--no-restart")) { // don't try to restart argsBase().m_restartable = false; } else if (isArg(i, argc, argv, NULL, "--restart")) { // try to restart argsBase().m_restartable = true; } else if (isArg(i, argc, argv, "-z", NULL)) { argsBase().m_backend = true; } else if (isArg(i, argc, argv, NULL, "--no-hooks")) { argsBase().m_noHooks = true; } else if (isArg(i, argc, argv, "-h", "--help")) { help(); m_bye(kExitSuccess); } else if (isArg(i, argc, argv, NULL, "--version")) { version(); m_bye(kExitSuccess); } else if (isArg(i, argc, argv, "-u", "--usb-list")) { // enumerate compatible usb devices list std::cout << CUSBAddress::getConnectedCompatibleDeviceNames(); m_bye(kExitSuccess); } else if (isArg(i, argc, argv, NULL, "--no-tray")) { argsBase().m_disableTray = true; } else if (isArg(i, argc, argv, NULL, "--ipc")) { argsBase().m_enableIpc = true; } else if (isArg(i, argc, argv, NULL, "--server")) { // HACK: stop error happening when using portable (synergyp) } else if (isArg(i, argc, argv, NULL, "--client")) { // HACK: stop error happening when using portable (synergyp) } else if (isArg(i, argc, argv, NULL, "--crypto-pass")) { argsBase().m_crypto.m_pass = argv[++i]; } else if (isArg(i, argc, argv, NULL, "--crypto-mode")) { argsBase().m_crypto.setMode(argv[++i]); } #if VNC_SUPPORT else if (isArg(i, argc, argv, NULL, "--vnc")) { argsBase().m_enableVnc = true; } #endif else { // option not supported here return false; } return true; }