Exemplo n.º 1
0
/*======================================================================*/
void usage(char *programName)
{
#if (BUILD+0) != 0
    printVersion(BUILD);
#else
    printVersion(0);
#endif
    printf("\n\nUsage:\n\n");
    printf("    %s [<switches>] <adventure>\n\n", programName);
    printf("where the possible optional switches are:\n");
#ifdef HAVE_GLK
    glk_set_style(style_Preformatted);
#endif
    printf("    -v       verbose mode\n");
    printf("    -l       log transcript to a file\n");
    printf("    -c       log player commands to a file\n");
    printf("    -n       no Status Line\n");
    printf("    -d       enter debug mode\n");
    printf("    -t[<n>]  trace game execution, higher <n> gives more trace\n");
    printf("    -i       ignore version and checksum errors\n");
    printf("    -r       make regression test easier (don't timestamp, page break, randomize...)\n");
#ifdef HAVE_GLK
    glk_set_style(style_Normal);
#endif
}
Exemplo n.º 2
0
int main(int argc, char* argv[]){
  float vNumber=0.3;
  CommandLineArgs myArgs{};
  if(!processCommandLine(argc, argv, myArgs)){
    std::cout<<"ERROR processing command line"<<"\n";
    return 1;
    }
  if (myArgs.wantHelp){
    printHelp();
    return 0;
    }
  if (myArgs.wantVers){
    printVersion(vNumber);
    return 0;
    }

  //std::cout<<"Command line inputted \n iValue = "<<(myArgs.iValue=="")<<"\n";

 // The readStream functions handle the input of strings. It calls the transformChar function to ensure that all alphabet characters are capitalised and any other characters are ignored. 
  std::string bigString{""};
  if (myArgs.iValue == ""){
    bigString= read(std::cin);
    }
  else{
    std::ifstream in_file {myArgs.iValue};
    if (in_file.good()){
      bigString=read(in_file);
      }
    else {
      std::cout<<"Input file not OK to read \n";
      return 1;
      }
    }
  //std::cout<<"Cipher choice = "<<myArgs.cipherChoice<<"\n";
  std::string result; 
  
  
  
  auto myCipher = CipherFactory(myArgs.cipherChoice, myArgs.kValue);    
  
  if (myArgs.encOrDec) result = myCipher->encrypt(bigString);
  else if (myArgs.encOrDec == false) result = myCipher->decrypt(bigString);
  else std::cout<<"ERROR: Not sure whether to encrypt or decrypt \n";
  
  // And now to out put the results
  if (myArgs.oValue==""){
    std::cout<<"Result is here: "<<result<<"\n";
    outPut(std::cout, result);
    }
  else {
    std::ofstream out_file{myArgs.oValue};
    if (out_file.good()){
      outPut (out_file, result);
    }
    else {
      return 1;
    }
  }

}
Exemplo n.º 3
0
int Tool::execute( cfg::cmd::CommandLine &cmd ) {
	if (cmd.isSet("set")) {
		set();
	}
	if (cmd.isSet("debug")) {
		debug();
	}

	if (cmd.isSet("help")) {
		printf("%s allowed options\n%s\n", name().c_str(), cmd.desc().c_str());
	} else if (cmd.isSet("version")) {
		printVersion();
	} else if (cmd.isSet("build")) {
		printBuild();
	} else if (cmd.isSet("pretend")) {
		pretend();
	} else if (cmd.isSet("defaults")) {
		defaults();
	} else {
		setupSignals();

		//	Initialize log system
		util::log::init();

		int result = run( cmd );

		//	Finalize log system
		util::log::fin();

		return result;
	}
	return 0;
}
Exemplo n.º 4
0
int PatcherApplication::run()
{
    if (args.containsKey('h', "help")) {
        printHelp();
        return Ok;
    }

    if (args.containsKey('v', "version")) {
        printVersion();
        return Ok;
    }

    if ( !isArgumentsValid(args) ) {
        printErrorMessage("", InvalidArguments);
        return InvalidArguments;
    }

    // --- main workflow
    std::string pathToQt = args.list().at(1);
    Error error = patchQtInDir(pathToQt);
    if (error != Ok) {
        printErrorMessage(pathToQt, error);
        return error;
    }

    return Ok;
}
Exemplo n.º 5
0
void printHelpInfo(){

	printVersion();
	Usage();
	Attention();

}
static int separationInit(int debugBOINC)
{
    int rc;
    MWInitType initType = MW_PLAIN;

  #if DISABLE_DENORMALS
    mwDisableDenormalsSSE();
  #endif

    mwFixFPUPrecision();

    if (debugBOINC)
        initType |= MW_DEBUG;

    if (SEPARATION_OPENCL)
        initType |= MW_OPENCL;

    rc = mwBoincInit(initType);
    if (rc)
        return rc;

    if (BOINC_APPLICATION && mwIsFirstRun())
    {
        /* Print the version, but only once for the workunit */
        printVersion(TRUE, FALSE);
    }

  #if (SEPARATION_OPENCL) && defined(_WIN32)
    /* We need to increase timer resolution to prevent big slowdown on windows when CPU is loaded. */
    mwSetTimerMinResolution();
  #endif /* defined(_WIN32) */

    return 0;
}
Exemplo n.º 7
0
/**
 * THE entry point for the application
 *
 * @param argc Number of arguments in array argv
 * @param argv Arguments array
 */
int main(int argc, char** argv)
{
    /* Create the Qt core application object */
    QApplication qapp(argc, argv);

#if defined(__APPLE__) || defined(Q_OS_MAC)
    /* Load plugins from within the bundle ONLY */
    QDir dir(QApplication::applicationDirPath());
    dir.cdUp();
    dir.cd("plugins");
    QApplication::setLibraryPaths(QStringList(dir.absolutePath()));
#endif

    /* Let te world know... */
    printVersion();

    /* Parse command-line arguments */
    if (parseArgs(argc, argv) == false)
        return 0;

    /* Load translation for current locale */
    loadTranslation(QLocale::system().name(), qapp);

    /* Create and initialize the Fixture Editor application object */
    App app;
    if (FXEDArgs::fixture.isEmpty() == false)
        app.loadFixtureDefinition(FXEDArgs::fixture);

    /* Show and execute the application */
    app.show();
    return qapp.exec();
}
Exemplo n.º 8
0
static void
usage(const char *message=NULL)
{
  if (message) fprintf(stderr,"%s: %s\n",argv0,message);
  fprintf(stderr,"usage: %s --path <path> [EXTRA_OPTIONS]\n",argv0);
  fprintf(stderr," -D|--database <name> : data base to use (default %s)\n",dbName);
  fprintf(stderr," -p|--path <path>     : full path to the table\n");
  fprintf(stderr," -t|--time <time>     : sets query time            (default: now)\n");
  fprintf(stderr," -x|--expire <time>   : sets query expiration time (default: forever)\n");
  fprintf(stderr," -F|--flavor          : set database flavor (default ofl)\n");
  fprintf(stderr," -f|--file <file>     : set file name for I/O  (default: stdin/stdout)\n");
  fprintf(stderr," -g|-r|--get|--read   : get (read)  data from database (default)\n");
  fprintf(stderr," -s|-w|--set|--write  : set (write) data to database\n");
  fprintf(stderr," -c|--comment <txt>   : set db comment   (default user id)\n");
  fprintf(stderr," -T|--tree            : print config tree\n");
  fprintf(stderr," -H|--history         : print time line for node\n");
  fprintf(stderr," -C|--config          : print available config versions\n");
  fprintf(stderr," -d|--dataonly        : don't write #node/table line, just the data\n");
  fprintf(stderr," -v|--verbose         : set verbose mode on\n");
  fprintf(stderr," -q|--quiet           : set quiet mode on\n");
  //fprintf(stderr," -w|--noWrite         : don't write #node/table line to the output\n");
  fprintf(stderr," -h|--help            : this short help\n");
  fprintf(stderr," supported time formats (cf. man date):\n");
  for(int i=0; dbTimeFormat[i]!=NULL ; i++ ) {
    const int MLEN=128;
    char tmpstr[MLEN];
    time_t t = time(0);
    strftime(tmpstr,MLEN,dbTimeFormat[i],gmtime(&t));
    fprintf(stderr,"  %-20s  e.g.: %s\n",dbTimeFormat[i],tmpstr);
  }
  fprintf(stderr,"%s\n",printVersion());
  if(message) exit(-1);
  return;
}
Exemplo n.º 9
0
//------------------------------------------------------------------------------
int main(int argc, char **argv) {
  prgm_opt::variables_map option_map;
  prgm_opt::options_description options("Options");

  try {
    prgm_opt::arg="[Value]";
    options.add_options()
      (CMDOPTIONS::HELP_OPTION[0],CMDOPTIONS::HELP_OPTION[2])
      (CMDOPTIONS::PERCOLATORFILE_OPTION[0],prgm_opt::value<string>()->required(),CMDOPTIONS::PERCOLATORFILE_OPTION[2])
      (CMDOPTIONS::MZIDFILE_OPTION[0],prgm_opt::value<string>()->required(),CMDOPTIONS::MZIDFILE_OPTION[2])
      (CMDOPTIONS::INPUTDIR_OPTION[0],prgm_opt::value<string>()->required(),CMDOPTIONS::INPUTDIR_OPTION[2])
      (CMDOPTIONS::MZIDOUTPUT_OPTION[0],prgm_opt::value<string>()->required(),CMDOPTIONS::MZIDOUTPUT_OPTION[2])
      (CMDOPTIONS::OUTPUTDIR_OPTION[0],prgm_opt::value<string>()->required(),CMDOPTIONS::OUTPUTDIR_OPTION[2])
      (CMDOPTIONS::DECOY_OPTION[0],CMDOPTIONS::DECOY_OPTION[2])
      (CMDOPTIONS::VALIDATION_OPTION[0],CMDOPTIONS::VALIDATION_OPTION[2])
      (CMDOPTIONS::WARNING_OPTION[0],CMDOPTIONS::WARNING_OPTION[2]);
    prgm_opt::store(prgm_opt::parse_command_line(argc,argv,options),option_map);
    if (option_map.count(CMDOPTIONS::HELP_OPTION[1])) {
      printVersion();
      cout << options;
      CleanUp(EXIT_SUCCESS);
      }
    if (option_map.count(CMDOPTIONS::DECOY_OPTION[1]))
      percolator.setDecoy();
    if (option_map.count(CMDOPTIONS::VALIDATION_OPTION[1])) {
      percolator.unsetValidation();
      mzid.unsetValidation();
      }
    if (option_map.count(CMDOPTIONS::WARNING_OPTION[1]))
       percolator.unsetWarningFlag();
    if (option_map.count(CMDOPTIONS::MZIDOUTPUT_OPTION[1]))
      mzid.setOutputFileEnding(option_map[CMDOPTIONS::MZIDOUTPUT_OPTION[1]].as<string>());
    if (option_map.count(CMDOPTIONS::INPUTDIR_OPTION[1]))
      if (!percolator.setInputDirectory(option_map[CMDOPTIONS::INPUTDIR_OPTION[1]].as<string>()))
        THROW_ERROR(PRINT_TEXT::MZIDINPUTDIR_NOT_FOUND);
    if (option_map.count(CMDOPTIONS::OUTPUTDIR_OPTION[1]))
      if (!mzid.setOutputDirectory(option_map[CMDOPTIONS::OUTPUTDIR_OPTION[1]].as<string>()))
        THROW_ERROR(PRINT_TEXT::MZIDOUTPUTDIR_NOT_CREATED);
    if (option_map.count(CMDOPTIONS::PERCOLATORFILE_OPTION[1]))
      if (!percolator.setFilename(option_map[CMDOPTIONS::PERCOLATORFILE_OPTION[1]].as<string>()))
        THROW_ERROR_VALUE(PRINT_TEXT::NO_PERCOLATOR_FILE,option_map[CMDOPTIONS::PERCOLATORFILE_OPTION[1]].as<string>());
    if (option_map.count(CMDOPTIONS::MZIDFILE_OPTION[1])) {
      percolator.multiplemzidfiles=false;
      if (!percolator.addFilenames(option_map[CMDOPTIONS::MZIDFILE_OPTION[1]].as<string>(),false))
        THROW_ERROR("");
      }
    if (percolator.noFilename())
      THROW_ERROR(PRINT_TEXT::PERCOLATOR_FILE_NOT_ENTERED);
    xercesc::XMLPlatformUtils::Initialize();
    if (!percolator.getPoutValues())
      THROW_ERROR(PRINT_TEXT::CANNOT_LOAD_PERCOLATOR_FILE);
    if (!mzid.insertMZIDValues(percolator.pout_values,percolator.mzidfilenames,percolator.multiplemzidfiles))
      THROW_ERROR(PRINT_TEXT::CANNOT_INSERT);
    CleanUp(EXIT_SUCCESS);
    }
  catch(exception &e) {
    cerr << e.what() << endl;
    CleanUp(EXIT_FAILURE);
    }
  }
Exemplo n.º 10
0
static s32 readFromArgs(s32 argc, const char* argv[], ocrConfig_t * ocrConfig) {
    // Override any env variable with command line option
    s32 cur = 1;
    s32 userArgs = argc;
    char * ocrOptPrefix = "-ocr:";
    s32 ocrOptPrefixLg = strlen(ocrOptPrefix);
    while(cur < argc) {
        const char * arg = argv[cur];
        if (strncmp(ocrOptPrefix, arg, ocrOptPrefixLg) == 0) {
            // This is an OCR option
            const char * ocrArg = arg+ocrOptPrefixLg;
            if (strcmp("cfg", ocrArg) == 0) {
                checkNextArgExists(cur, argc, "cfg");
                setIniFile(ocrConfig, argv[cur+1]);
                argv[cur] = NULL;
                argv[cur+1] = NULL;
                cur++; // skip param
                userArgs-=2;
            } else if (strcmp("version", ocrArg) == 0) {
                printVersion();
                exit(0);
                break;
            } else if (strcmp("help", ocrArg) == 0) {
                printHelp();
                exit(0);
                break;
            }
        }
        cur++;
    }
    return userArgs;
}
Exemplo n.º 11
0
void initProgram(int argc, char ** argv, char ** envp)
{
	cfg.argc = argc;
	cfg.argv = argv;
	cfg.envp = envp;
	cfg.help = 0;
	cfg.debug = 0;
	cfg.daemon = 0;
	cfg.version = 0;
	cfg.syslog = 0;

	cfg.port = 0;
	cfg.passkey = NULL;

	initOptions();

	printDebug();
	printHelp();
	printVersion();

	signal(SIGINT, mySignal);

	daemonize();
	initLogging();

	initServer();
}
Exemplo n.º 12
0
void readArgument(QApplication &app)
{
    auto args = QCoreApplication::arguments();
    auto name = QFileInfo{args.at(0)}.fileName();

    for (int i = 1; i < args.size(); ++i) {
        auto arg = args.at(i);

        if (arg.compare("-d") == 0 || arg.compare("--debug") == 0) {
            qInstallMessageHandler(debugMessageHandler);

        } else if (arg.compare("-v") == 0 || arg.compare("--version") == 0) {
            printVersion();
            exit(0);

        } else if (arg.compare("-h") == 0 || arg.compare("--help") == 0) {
            printHelp(name);
            exit(0);

        } else {
            printUnknownArgs(arg);
            printHelp(name);
            exit(1);
        }
    }
}
Exemplo n.º 13
0
Arquivo: dog.c Projeto: pratapl/COSC50
/* prints help option */
void printHelp()
{
    printVersion();
    printf("----------------------\n");
    printf("Command: dog\n");
    printf("Usage: dog [-n] [-m filename] [-M filename] [filename]\n");
    printf("switch: --help for this option\n");

}
Exemplo n.º 14
0
int main(int argc, char *argv[])
{
    /* Declarations */
    int c, option_index = 0;
    struct option long_options[] =
    {
        {"instrument-number", required_argument, 0, 'i'},
        {"sample-number", required_argument, 0, 's'},
        {"frequency", required_argument, 0, 'f'},
        {"help", no_argument, 0, 'h'},
        {"version", no_argument, 0, 'v'},
        {0, 0, 0, 0}
    };
    char *filename;
    unsigned int playAllInstruments = TRUE;
    unsigned int instrumentNumber = 0;
    unsigned int playAllSamples = TRUE;
    unsigned int sampleNumber = 0;
    int frequency = 22050;

    /* Parse command-line options */
    while((c = getopt_long(argc, argv, "i:s:f:hv", long_options, &option_index)) != -1)
    {
        switch(c)
        {
            case 'i':
                playAllInstruments = FALSE;
                instrumentNumber = atoi(optarg);
                break;
            case 's':
                playAllSamples = FALSE;
                sampleNumber = atoi(optarg);
                break;
            case 'f':
                frequency = atoi(optarg);
                break;
            case 'h':
                printUsage(argv[0]);
                return 0;
            case '?':
                printUsage(argv[0]);
                return 1;
            case 'v':
                printVersion(argv[0]);
                return 0;
        }
    }
    
    /* Validate non options */
    
    if(optind >= argc)
        filename = NULL;
    else
        filename = argv[optind];
    
    return SDL_8SVX_play8SVXSamples(filename, playAllInstruments, instrumentNumber, playAllSamples, sampleNumber, frequency);
}
Exemplo n.º 15
0
static void usage()
      {
      printVersion();
      printf("Usage: xml2smf [args] [infile] [outfile]\n");
      printf("   args:\n"
             "      -v      print version\n"
             "      -d      debug mode\n"
            );
      }
Exemplo n.º 16
0
bool parseCommandLine(const std::vector<Common::UString> &argv, int &returnValue,
                      Common::UString &cdpthFile, Common::UString &twoDAFile,
                      Common::UString &outFile) {

	std::vector<Common::UString> args;

	bool optionsEnd = false;
	for (size_t i = 1; i < argv.size(); i++) {
		// A "--" marks an end to all options
		if (argv[i] == "--") {
			optionsEnd = true;
			continue;
		}

		// We're still handling options
		if (!optionsEnd) {
			// Help text
			if ((argv[i] == "-h") || (argv[i] == "--help")) {
				printUsage(stdout, argv[0]);
				returnValue = 0;

				return false;
			}

			if (argv[i] == "--version") {
				printVersion();
				returnValue = 0;

				return false;
			}

			if (argv[i].beginsWith("-") || argv[i].beginsWith("--")) {
			  // An options, but we already checked for all known ones

				printUsage(stderr, argv[0]);
				returnValue = -1;

				return false;
			}
		}

		args.push_back(argv[i]);
	}

	if (args.size() != 3) {
		printUsage(stderr, argv[0]);
		returnValue = -1;

		return false;
	}

	cdpthFile = args[0];
	twoDAFile = args[1];
	outFile   = args[2];

	return true;
}
Exemplo n.º 17
0
/**
 * THE entry point for the application
 *
 * @param argc Number of arguments in array argv
 * @param argv Arguments array
 */
int main(int argc, char** argv)
{
    /* Create the Qt core application object */
    QApplication qapp(argc, argv);

    /* At least MIDI plugin requires this so best to declare it here for everyone */
    qRegisterMetaType<QVariant>("QVariant");

#ifdef __APPLE__
    /* Load plugins from within the bundle ONLY */
    QDir dir(QApplication::applicationDirPath());
    dir.cdUp();
    dir.cd("plugins");
    QApplication::setLibraryPaths(QStringList(dir.absolutePath()));
#endif

    QLCi18n::init();

    /* Let the world know... */
    printVersion();

    /* Parse command-line arguments */
    if (parseArgs() == false)
        return 0;

    /* Load translation for main application */
    QLCi18n::loadTranslation("qlcplus");

    /* Handle debug messages */
    qInstallMsgHandler(qlcMessageHandler);

    /* Create and initialize the QLC application object */
    App app;

#if defined(WIN32) || defined(__APPLE__)
    if (QLCArgs::debugLevel < QtSystemMsg)
    {
        QLCArgs::dbgBox = new DebugBox(&app);
        QLCArgs::dbgBox->show();
    }
#endif
    app.startup();
    app.show();

    if (QLCArgs::workspace.isEmpty() == false)
        app.loadXML(QLCArgs::workspace);
    if (QLCArgs::operate == true)
        app.slotModeOperate();
    if (QLCArgs::kioskMode == true)
        app.enableKioskMode();
    if (QLCArgs::fullScreen == true)
        app.slotControlFullScreen(QLCArgs::fullScreenResize);
    if (QLCArgs::kioskMode == true && QLCArgs::closeButtonRect.isValid() == true)
        app.createKioskCloseButton(QLCArgs::closeButtonRect);

    return qapp.exec();
}
Exemplo n.º 18
0
 void setOption(int c, string& option_arg)
 {
     switch (c)
     {
     case 'V':
         printVersion();
         exit(0);
     }
 }
Exemplo n.º 19
0
void CommandLine::printHelp(std::ostream& out)
{
  printVersion(out); 

  out << std::endl << "Usage: " << (isYggdrasil ? "./yggdrasil" : "./exabayes"  ) <<  " -f alnFile [ -q modelFile ] [ -m model ] [ -s seed | -r id ]  -n id [options..] "
      << std::endl; 

  
  out << "\n\n"
      << "================================================================\n"
      << "Mandatory Arguments: \n"
      << "================================================================\n\n"
      << "    -f alnFile       a alignment file (either binary and created by parser or plain-text phylip)\n\n"
      << "    -s seed          a master seed for the MCMC\n\n"
      << "    -n ruid          a run id\n\n" 
      << "    -r id            restart from checkpoint. Just specify the id of the previous run (-n) here. \n"
      << "                       Make sure, that all files created by the previous run are in the working directory.\n"
      << "                       This option is not mandatory for the start-up, seed (via -s) will be ignored.\n\n"
      << "    -q modelfile     a RAxML-style model file (see manual) for multi-partition alignments. Not needed \n"
      << "                       with binary files.\n\n"
      << "    -t treeFile      a file containing starting trees (in Newick format) for chains. If the file provides less\n"
      << "                       starting trees than chains to be initialized, parsimony/random trees will be used for\n"
      << "                       remaining chains. If a tree contains branch lengths, these branch lengths will be used\n"
      << "                       as initial values.\n\n"
      << "    -m model         indicates the type of data for a single partition non-binary alignment file\n" 
      << "                       (valid values: BIN, DNA or PROT)\n\n"
      << std::endl;     

  out <<      "\n" 
      << "================================================================\n"
      <<  "Options:\n" 
      << "================================================================\n\n"
      << "    -v               print version and quit\n\n"
      << "    -h               print this help\n\n" 
      << "    -z               quiet mode. Substantially reduces the information printed by " << PROGRAM_NAME << ".\n"
      << "                      This option will save you some idle time, when you run " << PROGRAM_NAME << " with a\n"
      << "                      lot of processes.\n\n" 
      << "    -d               execute a dry-run. Procesess the input, but does not execute any sampling.\n\n"
      << "    -c confFile      a file configuring your " << PROGRAM_NAME << " run. For a template see the 'examples' folder.\n\n"
      << "    -w dir           specify a working directory for output files\n\n"; 

  out << "    -R num           the number of runs (i.e., independent chains) to be executed in parallel\n\n"
      << "    -C num           number of chains (i.e., coupled chains) to be executed in parallel\n\n" 
      << "    -x               disables thread pinning (which schedules a thread to a cpu core\n"
      << "                       in a fixed way). You should try this function, if you notice load imbalances with the\n"
      << "                       threaded version of the code (i.e., using -T x).\n\n" ;  
  
  out << "    -S               try to save memory using the SEV-technique for gap columns on large gappy alignments\n" 
      << "                       Please refer to  http://www.biomedcentral.com/1471-2105/12/470\n" 
      << "                       On very gappy alignments this option yields considerable runtime improvements. \n\n"
      << "    -T x             start x threads per MPI process. If you do not use MPI, simply start x threads. \n\n" 
      << "    -M mode          specifies the memory versus runtime trade-off (see manual for detailed discussion).\n"
      << "                       <mode> is a value between 0 (fastest, highest memory consumption) and 3 (slowest,\n"
      << "                       least memory consumption)\n\n"
      << std::endl; 
}
int main(int argc, const char* argv[])
{
    int rc;
    SeparationFlags sf;
    SeparationPrefs preferences;
    const char** argvCopy = NULL;

  #ifdef NDEBUG
    mwDisableErrorBoxes();
  #endif /* NDEBUG */

    argvCopy = mwFixArgv(argc, argv);
    rc = parseParameters(argc, argvCopy ? argvCopy : argv, &sf);
    if (rc)
    {
        if (BOINC_APPLICATION)
        {
            freeSeparationFlags(&sf);
            mwBoincInit(MW_PLAIN);
            parseParameters(argc, argvCopy, &sf);
            printVersion(TRUE, FALSE);
        }

        mw_printf("Failed to parse parameters\n");
        free(argvCopy);
        mw_finish(EXIT_FAILURE);
    }


    rc = separationInit(sf.debugBOINC);
    free(argvCopy);
    if (rc)
        return rc;

    separationReadPreferences(&preferences);
    setFlagsFromPreferences(&sf, &preferences, argv[0]);

    if (sf.processPriority != MW_PRIORITY_INVALID)
    {
        mwSetProcessPriority(sf.processPriority);
    }

    rc = worker(&sf);

    freeSeparationFlags(&sf);

    if (!sf.ignoreCheckpoint && sf.cleanupCheckpoint && rc == 0)
    {
        mw_report("Removing checkpoint file '%s'\n", CHECKPOINT_FILE);
        mw_remove(CHECKPOINT_FILE);
    }

    mw_finish(rc);
    return rc;
}
Exemplo n.º 21
0
/** The main thing.
 * @param argc the number of tokens on the input line.
 * @param argv an array of tokens.
 * @return 0 on success, 1-255 on failure
 */
int main (int argc, char *argv[])
{
  if (argc < 2)
  {
    printf("Usage: mytar [ctxvS]f tarfile [ path [ ... ] ]\n");
    exit(EXIT_FAILURE);
  }

  if (argv[1][0] == '-')
    parser2(argc, argv);
  else
    parser(argv[1]);

  /* Report the final status of the flags */
  if (!f_flag && !help_flag && !version_flag)
  {
    printf("-f option is required\n");
    exit(EXIT_FAILURE);
  }
  else if (help_flag)
    printHelp();
  else if (version_flag)
    printVersion();

  if (!c_flag && !t_flag && !x_flag && !help_flag && !version_flag)
  {
    printf("One operation -c -t or -x is required\n");
    exit(EXIT_FAILURE);
  }

  if ((c_flag && t_flag) || (c_flag && x_flag) || (x_flag && t_flag))
  {
    printf("Only one operation -c -t or -x can be specified\n");
    exit(EXIT_FAILURE);
  }
  
  if (t_flag && f_flag)
  {
    readFile(argv[2]);
  }
  
  if (c_flag)
  {
    printf("Implemented but not properly functioning.\n");
    exit(EXIT_FAILURE);
  }
  if (x_flag)
  {
    printf("Not implemented.\n");
    exit(EXIT_FAILURE);
  }
  
  return EXIT_SUCCESS;
}
Exemplo n.º 22
0
void parseArgs(int argc, char* argv[]) {
    for (int i = 0; i < argc; i++){
        if (!strcmp(argv[i],"--help") || !strcmp(argv[i],"-h")){
            printHelp();
            exit(0);
        }
        else if (!strcmp(argv[i],"--version") || !strcmp(argv[i],"-v")){
            printVersion();
            exit(0);
        }
    }
}
Exemplo n.º 23
0
static void printUsage(poptContext con, FILE * fp, int flags)
	/*@globals rpmEVR, fileSystem, internalState @*/
	/*@modifies *fp, fileSystem, internalState @*/
{
    printVersion(fp);
    fprintf(fp, "\n");

    if (rpmIsVerbose())
	poptPrintHelp(con, fp, flags);
    else
	poptPrintUsage(con, fp, flags);
}
Exemplo n.º 24
0
void printHelpMessage(const char *executable)
{
    printVersion(true);
    std::cout<<std::endl;

    std::cout<<"usage: "<<executable<<" [-h/--help] [-v/--version] [-c/--config <file>]"<<std::endl;

    std::cout<<"options:"<<std::endl;
    std::cout<<" -h/--help\t\tshow this help and exit"<<std::endl;
    std::cout<<" -v/--version\t\tshow version and exit"<<std::endl;
    std::cout<<" -c/--config <file>\tconfig file to use"<<std::endl;
}
Exemplo n.º 25
0
void ofPackageManager::doctor()
{
	printVersion();

	// check version of ofPackageManager
	ofHttpResponse request = ofLoadURL("https://raw.githubusercontent.com/thomasgeissl/ofPackageManager/master/defines.h");
	auto defines = request.data.getText();
	int majorVersion = 0;
	int minorVersion = 0;
	int patchVersion = 0;
	auto lines = ofSplitString(defines, "\n");
	for (auto line : lines)
	{
		auto parts = ofSplitString(line, " ");
		if (parts.size() == 3)
		{
			if (parts[1] == "major")
			{
				majorVersion = ofToInt(parts[2]);
			}
			else if (parts[1] == "minor")
			{
				minorVersion = ofToInt(parts[2]);
			}
			else if (parts[1] == "patch")
			{
				patchVersion = ofToInt(parts[2]);
			}
		}
	}
	ofJson mostRecentVersionJson;
	// mostRecentVersionJson = ofJson::parse(request.data.getText());
	mostRecentVersionJson["major"] = majorVersion;
	mostRecentVersionJson["minor"] = minorVersion;
	mostRecentVersionJson["patch"] = patchVersion;
	ofJson currentVersion = getVersionJson();
	if (
		mostRecentVersionJson["major"].get<int>() > currentVersion["major"].get<int>() ||
		mostRecentVersionJson["minor"].get<int>() > currentVersion["minor"].get<int>() ||
		mostRecentVersionJson["patch"].get<int>() > currentVersion["patch"].get<int>())
	{
		ofLogNotice("doctor") << "There is a new version of ofPackageManager available";
		ofLog::setAutoSpace(false);
		ofLogNotice("doctor") << "The most recent version is " << mostRecentVersionJson["major"] << "." << mostRecentVersionJson["minor"] << "." << mostRecentVersionJson["patch"];
		ofLog::setAutoSpace(true);
	}
	else
	{
		ofLogNotice("doctor") << "You are up to date. Currently there is no newer version of ofPackageManager available";
	}

	// check version of ofPackages
}
Exemplo n.º 26
0
/**
	@internal

	Prints version and usage information to stderr.	

	@param[in] 	appName 	the application's name (argv[0])
*/
static void printUsage(const char *appName)
{
	printVersion(appName);
	fprintf(stderr,
		"Usage: %s [-v|-h] [-p] [-b <filename>] <file list>\n"
		"    -v, --version    print version message\n"
		"    -h, --help       print usage message\n"
		"    -p               only emit function comments and prototypes\n"
		"    -b <filename>    provide a 'boilerplate' file for the file comment\n"
		"if <file list> is empty, process stdin to stdout.\n"
	, appName );
}
Exemplo n.º 27
0
void parseCommandLineArgs(int argc, char* argv[])
{
    int next_option;
	
    // getopt structures
    const char* const short_options = "c:sqihv";

    const struct option long_options[] = {
        { "config",      required_argument, 0, 'c' },
	{ "silent",      no_argument,       0, 's' },
	{ "quiet",       no_argument,       0, 'q' },
        { "insensitive", no_argument,       0, 'i' },
	{ "help",        no_argument,       0, 'h' },
	{ "version",     no_argument,       0, 'v' },
	{ 0, 0, 0, 0 }
    };

    do {
	next_option = getopt_long( argc, argv, 
				   short_options, long_options, NULL );
		
	switch( next_option ) {
          case 'c': // -- config of -f option
            config = optarg;
            break;
          case 's': // --silent or -s option
          case 'q': // --quiet or -q option
	    silent_mode = true;
	    break;
          case 'i': // --insensitive or -i option
            case_insensitive = true;
            break;
          case 'h': // --help or -h option
	    printUsage();
	    exit (0);
	    break;
          case 'v': // --version or -v option
            printVersion();
            exit (0);
	    break;
          case '?': // unknown option
	    printUsage();
	    exit (0);
	    break;
          case -1:
	    break;
          default:
	    abort();
	}

    } while( next_option != -1 );
}
Exemplo n.º 28
0
void parseArguments(int argc, char **argv)
{
    static const char short_options [] = "hvnP:L:p:";

    static const struct option
        long_options [] = {
        { "help",       no_argument, NULL, 'h' },
        { "version",    no_argument, NULL, 'v' },
        { "pidfile",    required_argument, NULL, 'P' },
        { "logfile",    required_argument, NULL, 'L' },
        { "port",       required_argument, NULL, 'p' },
        { "nodaemon",   no_argument, NULL, 'n' },
        { 0, 0, 0, 0 }
    };

    for (;;) {
        int index, c = 0;

        c = getopt_long(argc, argv, short_options, long_options, &index);

        if (-1 == c)
            break;

        switch (c) {
        case 0: /* getopt_long() flag */
            break;

        case 'h':
            usage(stdout, argc, argv);
            exit(EXIT_SUCCESS);
        case 'v':
            printVersion(stdout);
            exit(EXIT_SUCCESS);
        case 'P':
            pidFile = optarg;
            break;
        case 'L':
            logFile = optarg;
            break;
        case 'p':
            port = atoi(optarg);
            break;
        case 'n':
            nodaemon = 1;
            break;

        default:
            usage(stderr, argc, argv);
            exit(EXIT_FAILURE);
        }
    }
}
Exemplo n.º 29
0
/**
 * Parses the command line and calls the right functions.
 *
 * Call this function after creating a QApplication.
 *
 * @param[in] argc the number of arguments
 * @param[in] argv an array of strings
 */
void Qpamat::parseCommandLine(int argc, char **argv)
{
    for (int i = 1; i < argc; ++i) {
        QString string = QString::fromLatin1(argv[i]);
        if (string == "-h" || string == "--help" || string == "-help") {
            printCommandlineOptions();
            std::exit(0);
        } else if (string == "v" || string == "--version" || string == "-version") {
            printVersion();
            std::exit(0);
        }
    }
}
Exemplo n.º 30
0
void usage(const wxString &executable)
{
	wxFileName *fn = new wxFileName(executable);
	printVersion();

	wxPrintf(_("Usage:\n"));
	wxPrintf(fn->GetName() + _(" [options] <connect-string>\n"));
	wxPrintf(_("options:\n"));
	wxPrintf(_("-v (display version info and then exit)\n"));
	wxPrintf(_("-f run in the foreground (do not detach from the terminal)\n"));
	wxPrintf(_("-t <poll time interval in seconds (default 10)>\n"));
	wxPrintf(_("-r <retry period after connection abort in seconds (>=10, default 30)>\n"));
	wxPrintf(_("-s <log file (messages are logged to STDOUT if not specified>\n"));
	wxPrintf(_("-l <logging verbosity (ERROR=0, WARNING=1, DEBUG=2, default 0)>\n"));
}