Exemple #1
0
int ledctrl_main(int argc, char **argv)
{
    PLED_NAME_MAP namePtr = ledNameMap;
    PLED_STATE_MAP statePtr = ledStateMap;

    if (argc < 3)
        showUsage();

    while (namePtr->validLedName)
        if (strcmp(namePtr->validLedName, argv[1]) == 0)
            break;
        else
            namePtr++;
    if (!namePtr->validLedName)
        showUsage();

    while (statePtr->validLedState)
        if (strcmp(statePtr->validLedState, argv[2]) == 0)
            break;
        else
            statePtr++;

    if (!statePtr->validLedState)
        showUsage();

    sysLedCtrl(namePtr->ledName, statePtr->ledState);

	return 0;

}
Exemple #2
0
/*------------------------------------------------------------------------------
 *  Program entry point
 *----------------------------------------------------------------------------*/
int
main (
    int     argc,
    char  * argv[] )
{
    int     res = -1;

    std::cout << "DarkIce " << VERSION
         << " live audio streamer, http://darkice.sourceforge.net"
         << std::endl
         << "Copyright (c) 2000-2004, Tyrell Hungary, http://tyrell.hu"
         << std::endl << std::endl;

    try {
        const char    * configFileName = 0;
        unsigned int    verbosity      = 1;
        int             i;
        const char      opts[] = "hc:v:";

        while ( (i = getopt( argc, argv, opts)) != -1 ) {
            switch ( i ) {
                case 'c':
                    configFileName = optarg;
                    break;

                case 'v':
                    verbosity = Util::strToL( optarg);
                    break;

                default:
                case ':':
                case '?':
                case 'h':
                    showUsage( std::cout);
                    return 1;
            }
        }

        if ( !configFileName ) {
            showUsage( std::cout);
            throw Exception( __FILE__, __LINE__,
                             "no configuration file specified");
        }

        std::cout << "Using config file: " << configFileName << std::endl;

        std::ifstream       configFile( configFileName);
        Config              config( configFile);
        Ref<DarkIce>        di = new DarkIce( config);
        di->setReportVerbosity( verbosity );
        di->setReportOutputStream( std::cout );

        res = di->run();

    } catch ( Exception   & e ) {
        std::cout << "DarkIce: " << e << std::endl << std::flush;
    }

    return res;
}
Exemple #3
0
int n64_main(int argc, char* argv[]) {
	init();
	if (argc==1) {
		test();
		dumpCutoffs();
	}
	else if (!strcmp("generateFlipFunctions", argv[1])) {
		extern void generateFlipFunctions();
		generateFlipFunctions();
	}
	else if (!strcmp("generateSolverTestPositions", argv[1])) {
		if (argc < 3) {
			showUsage();
		}
		else {
			const int depth = atoi(argv[2]);
			generateSolverTestPositions(depth);
		}
	}
	else if (!strcmp("timeSolves", argv[1])) {
		if (argc < 3) {
			showUsage();
		}
		else {
			const int depth = atoi(argv[2]);
			timeSolves(1, depth, false);
		}
	}
	else if (!strcmp("timeWld", argv[1])) {
		if (argc < 3) {
			showUsage();
		}
		else {
			const int depth = atoi(argv[2]);
			timeSolves(1, depth, true);
		}
	}
	else if (!strcmp("stats", argv[1])) {
		if (argc < 3) {
			showUsage();
		}
		else {
			const int depth = atoi(argv[2]);
			timeSolves(1, depth, true);
		}
		dumpCutoffs();
	}
	else if (!strcmp("timeMobility", argv[1])) {
		extern void timeMobility();
		timeMobility();
	}
	else {
		showUsage();
	}

	return 0;
}
Exemple #4
0
int main(int argc, char** argv) {
	std::vector<Argument> arguments = createArguments();
	ArgumentParser argumentParser;
	try {
		argumentParser.parse(argc, argv, arguments);
	} catch(const GeneralException& exception) {
		std::cout << exception.what() << std::endl;
		showUsage(arguments);
		return -1;
	}
	if (argumentParser.isArgumentPresent('h')) {
		showUsage(arguments);
		return 0;
	}
	if (!areAllMandatoryArgumentsPresent(argumentParser)) {
		showUsage(arguments);
		return -1;
	}
	try {
		FractalParser parser;
		FractalParams params = parser.readFractal(argumentParser.getStringArgument('f'));
		Database* database;
		int hardwareConcurrency = std::thread::hardware_concurrency();
		if (hardwareConcurrency == 0) {
			hardwareConcurrency = 1;
		}
		int numberOfThreads = argumentParser.getIntArgumentOrReturnDefault('t', hardwareConcurrency);
		bool saveTemporaryResult = !argumentParser.isArgumentPresent('s');
		std::cout << "Number of threads: " << numberOfThreads << std::endl;
		if (argumentParser.isArgumentPresent('b')) {
			database = new Database();
		} else {
			database = new Database(argumentParser.getStringArgumentOrReturnDefault('d', "points.ff"));
		}
		ValueProvider* valueProvider = new ValueProvider(database, params, numberOfThreads);
		valueProvider->setIterationCountToConsiderInteresting(argumentParser.getIntArgumentOrReturnDefault('i', 100));
		if (argumentParser.isArgumentPresent('o')) {
			valueProvider->setReadOnlyFile(true);
		}
		if (argumentParser.isArgumentPresent('b')) {
			valueProvider->setNoDb(true);
		}
		for (double d = params.startPower; d <= params.endPower; d+= params.increment) {
			valueProvider->deleteSavedValues();
			Fractal fractal(valueProvider, params);
			fractal.draw(d, numberOfThreads, saveTemporaryResult);
		}
		delete database;
		delete valueProvider;
	} catch(const GeneralException& ex) {
		std::cout << "Exception occured: " << ex.what() << std::endl;
		return -1;
	}
	return 0;
}
Exemple #5
0
int main(int argc, char** argv)
{
   bool daemon = true;
   char *ip = 0, *dest = 0;
   int opt, port = 0;
   while((opt = getopt(argc, argv, "hi:p:d:f")) != -1)
   {
      switch(opt)
      {
         case 'i':
            ip = strdup(optarg);
            break;
         case 'p':
            port = atoi(optarg);
            break;
         case 'd':
            dest = strdup(optarg);
            break;
         case 'h':
            showUsage();
            return 0;
            break;
         case 'f':
            daemon = false;
            break;
         case '?':
            showUsage();
            return 0;
            break;
      }
   }

   if((! port) || (! dest))
   {
      showUsage();
      return 1;
   }

   syslog(LOG_INFO, "Routing: %s:%d to: %s", (ip ? ip : "ALL"), port, dest);

   try
   {
      IpAddress ipAddr(ip, port);
      IpAddress destAddr(dest);
      SnmpRouted server(ipAddr, destAddr, daemon);
      syslog(LOG_INFO, "Started");
      server.run();
   }
   catch(NetErr& e)
   {
      syslog(LOG_ERR, "Exception %s", e.errm);
   }

   return 0;
}
Exemple #6
0
bool invalidArgs(int argc, char *argv[]) {
    if (argc < 2 || argc > 3) {
        fprintf(stderr, "Erro! Quantidade invalida de argumentos.\n");
        showUsage();
        return true;
    }
    if (strcmp(argv[1], "-S") != 0 && strcmp(argv[1], "host") != 0) {
        fprintf(stderr, "Erro! Argumento invalido: %s\n", argv[1]);
        showUsage();
        return true;
    }
    return false;
}
Exemple #7
0
static void parseArguments(int argc, char **argv)
{
  int i;

  programName = argv[0];

  /* Check for existence of at least the filename argument */

  if (argc < 2)
    {
      fprintf(stderr, "Invalid number of arguments\n");
      showUsage(); 
    }

  /* Parse any optional command line arguments */

  for (i = 1; i < argc-1; i++)
    {
      char *ptr = argv[i];
      if (ptr[0] == '-')
        {
          switch (ptr[1])
            {
            case 'I' :
              if (nIncPathes >= MAX_INCPATHES)
                {
                  fprintf(stderr, "Unrecognized [option]\n");
                  showUsage(); 
                }
              else
                {
                  includePath[nIncPathes] = &ptr[2];
                  nIncPathes++;
                }
              break;
            default:
              fprintf(stderr, "Unrecognized [option]\n");
              showUsage(); 
            }
        }
      else
        {
          fprintf(stderr, "Unrecognized [option]\n");
          showUsage(); 
        }
    }

  /* Extract the Pascal program name from the command line */

  sourceFileName = argv[argc-1];
}
/** \brief parse legacy nfd-status command line, and show usage if necessary
 *  \return if first item is -1, caller should retrieve and display StatusReport;
 *          otherwise, caller should immediately exit with the specified exit code
 */
static std::tuple<int, StatusReportOptions>
parseCommandLine(const std::vector<std::string>& args)
{
  StatusReportOptions options;

  namespace po = boost::program_options;
  po::options_description cmdOptions("StatusReportOptions");
  cmdOptions.add_options()
    ("help,h", "print this help message")
    ("version,V", "show program version")
    ("general,v", po::bool_switch(&options.wantForwarderGeneral), "show general status")
    ("channels,c", po::bool_switch(&options.wantChannels), "show channels")
    ("faces,f", po::bool_switch(&options.wantFaces), "show faces")
    ("fib,b", po::bool_switch(&options.wantFib), "show FIB entries")
    ("rib,r", po::bool_switch(&options.wantRib), "show RIB routes")
    ("sc,s", po::bool_switch(&options.wantStrategyChoice), "show strategy choice entries")
    ("xml,x", "output as XML instead of text (implies -vcfbrs)");
  po::variables_map vm;
  try {
    po::store(po::command_line_parser(args).options(cmdOptions).run(), vm);
    po::notify(vm);
  }
  catch (const po::error& e) {
    std::cerr << e.what() << "\n";
    showUsage(std::cerr, cmdOptions);
    return std::make_tuple(2, options);
  }

  if (vm.count("help") > 0) {
    showUsage(std::cout, cmdOptions);
    return std::make_tuple(0, options);
  }
  if (vm.count("version") > 0) {
    std::cout << "nfd-status " << NFD_VERSION_BUILD_STRING << "\n";
    return std::make_tuple(0, options);
  }

  if (vm.count("xml") > 0) {
    options.output = ReportFormat::XML;
  }
  if (options.output == ReportFormat::XML ||
      (!options.wantForwarderGeneral && !options.wantChannels && !options.wantFaces &&
       !options.wantFib && !options.wantRib && !options.wantStrategyChoice)) {
    options.wantForwarderGeneral = options.wantChannels = options.wantFaces =
      options.wantFib = options.wantRib = options.wantStrategyChoice = true;
  }

  return std::make_tuple(-1, options);
}
Exemple #9
0
void parseArguments(const std::list<std::string>& args)
{
    std::list<std::string>::const_iterator i;

    // Set up defaults
    options.verbose = false;
    options.minTime = 1;
    options.bitsPerPixel = 16;
    options.listTests = false;

    for (i = args.begin(), i++; i != args.end(); ++i)
    {
        if (*i == "-h" || *i == "--help")
        {
            showUsage();
            exit(0);
        }
        else if (*i == "-i" && ++i != args.end())
        {
            options.includedTests.push_back(*i);
        }
        else if (*i == "-e" && ++i != args.end())
        {
            options.excludedTests.push_back(*i);
        }
        else if (*i == "-t" && ++i != args.end())
        {
            options.minTime = atoi((*i).c_str());
        }
        else if (*i == "-b" && ++i != args.end())
        {
            options.bitsPerPixel = atoi((*i).c_str());
        }
        else if (*i == "-v")
        {
            options.verbose = true;
        }
        else if (*i == "-l")
        {
            options.listTests = true;
        }
        else
        {
            std::cerr << "Invalid option: " << *i << std::endl;
            showUsage();
            exit(1);
        }
    }
}
Exemple #10
0
int main(int argc,char** argv)
{
    /*
    arg1 : ID
    */
    if(argc < 2)
    {
        showUsage();
        exit(0);
    }

    pairing_t pairing;
    element_t s,Sa,Qa;
    pairing_from_file(pairing,"globalParam/pairingParam");
    element_init_G1(Sa,pairing);
    element_init_G1(Qa,pairing);
    element_init_Zr(s,pairing);

    element_from_file(s,"masterKey/s");
    element_from_hash(Qa,argv[1],strlen(argv[1]));
    element_mul_zn(Sa,Qa,s);

    char loc[100] = "privateKey/";
    strcat(loc,argv[1]);
    strcat(loc,".priv");
    element_to_file(Sa,loc);

    return 0;
}
Exemple #11
0
/*!
 * @brief コマンドライン引数の解析を行う
 *
 * 引数argvのうち、オプションに関係しないものは、後ろに並び替えられる。
 * その開始インデックスを返り値とする
 * @param [in]     argc      コマンドライン引数の数
 * @param [in,out] argv      コマンドライン引数
 * @param [out]    lang      音声合成の言語
 * @param [out]    filename  出力ファイル名
 * @return  残った引数のインデックス
 */
static int parseArguments(
    int          argc,
    char        *argv[],
    std::string &lang,
    std::string &filename)
{
  static const struct option opts[] = {
    {"help",     no_argument,       NULL, 'h'},
    {"language", required_argument, NULL, 'l'},
    {"output",   required_argument, NULL, 'o'},
    {0, 0, 0, 0}   // must be filled with zero
  };

  int ret;
  int optidx;
  while ((ret = getopt_long(argc, argv, "hl:o:", opts, &optidx)) != -1) {
    switch (ret) {
      case 'h':  // -h or --help
        showUsage(argv[0], EXIT_SUCCESS);
        break;
      case 'l':  // -l or --language
        lang = optarg;
        break;
      case 'o':  // -o or --output
        filename = optarg;
        break;
    }
  }
  return optind;
}
Exemple #12
0
void parse_arg( int argc, char * argv[] )
{
	extern char *optarg ;
	int c ;

	while( ( c = getopt ( argc, argv, "h:p:c:m:w:s:v" )) != EOF ) {
		switch ( c ) {
			case 'h' :
				gHost = optarg;
				break;
			case 'p':
				gPort = atoi( optarg );
				break;
			case 'c' :
				gClients = atoi ( optarg );
				break;
			case 'm' :
				gMsgs = atoi( optarg );
				break;
			case 'w':
				gConnWait = atoi( optarg );
				break;
			case 's':
				gSockWait = atoi( optarg );
				break;
			case 'v' :
			case '?' :
				showUsage( argv[0] );
				exit( 0 );
		}
	}
}
int main(int argc, char **argv) {
	if (argc != 3) {
		showUsage();
		return 1;
	}

	int securityLevel = atoi(argv[1]);
	string rngSeed(argv[2]);
	size_t rngSeedLength = 16;

	string fullLine;
	string line;
	while (getline(cin, line)) {
		fullLine.append(line);
	}
	byte *inputData = (byte *) fullLine.data();
	int inputLength = fullLine.length();

	RegisterFactories();
	rngSeed.resize(rngSeedLength);
	s_globalRNG.SetKeyWithIV((byte *)rngSeed.data(), rngSeedLength, (byte *)rngSeed.data());

	int securityIndex = 0;
	for (int i = 0; i < NUMBER_OF_SECURITY_LENGTHS; i++) {
		if (securityLevels[i] == securityLevel) {
			securityIndex = i;
			break;
		}
	}
	
	ProfileSignatureSchemes(inputData, inputLength, securityIndex);
}
// Return the image specified on the command line.
//
static cv::Mat useCommandLine(int ac, const char *av[])
{
    cv::Mat result;
    if (ac == 2) result = cv::imread(av[1]);
    if (!result.data) showUsage(av[0]);
    return result;
}
Exemple #15
0
void
cmdargParse(const char **argv)
{
    argv0 = argv[0];
    for (argv++; *argv != NULL; argv++) {
	if ((*argv)[0] == '-') {
	    switch ((*argv)[1]) {
	    case 'c': /* -c <commx args>*/
		cmdarg.ttymode = CA_COMMX;
		cmdarg.commx = *++argv;
		if (cmdarg.commx == NULL) goto FEWARG;
		break;
	    case 'd': /* -d <pty_device>*/
		cmdarg.ttymode = CA_DEVGIVEN;
		cmdarg.dev = *++argv;
		if (cmdarg.dev == NULL) goto FEWARG;
		break;
	    case 'e': /* -e <atcommands>*/
		cmdarg.atcmd = *++argv;
		if (cmdarg.atcmd == NULL) goto FEWARG;
		break;
	    case 'h': /* -h */
		showUsage();
		exit(0);
	    case 's': /* -s */
		cmdarg.ttymode = CA_SHOWDEV;
		break;
	    case '\0': /* - */
		cmdarg.ttymode = CA_STDINOUT;
		break;
	    default:
		fprintf(stderr, "Unknown option -%c.\n", (*argv)[1]);
		showUsage();
		exit(1);
	    }
	} else {
	    fprintf(stderr, "Error in command line.\n");
	    showUsage();
	    exit(1);
	}
    }
    return;

 FEWARG:
    fprintf(stderr, "'-%c' requires an argument.\n", (*--argv)[1]);
    exit(1);
}
bool Display::parseCommandLine()
{
  parseError = false;
  if (argc_ < 2)
  {
    parseError = true;
    //showUsage();
    return false;
  }
  if (argv_[1][0] == '/')
  {
    showUsage();
    return 1;
  }
  path_ = argv_[1];
  if (!FileSystem::Directory::exists(path_))
  {
    std::cout << "\n  can't find directory \"" << path_ << "\"";
    parseError = true;
    return false;
  }
  // find options and patterns,
  // ignore unrecognized options, accept all patterns

  optionState_[s] = false;
  optionState_[a] = false;
  optionState_[d] = false;
  optionState_[f] = false;
  optionState_[q] = false;
  optionState_[c] = false;

  for (int i = 2; i < argc_; ++i)
  {
    if (argv_[i][0] == '/')
    {
      switch (argv_[i][1])
      {
      case 's': optionState_[s] = true; break;
      case 'a': optionState_[a] = true; break;
      case 'd': optionState_[d] = true; break;
      case 'f':
        optionState_[f] = true;
        searchText_ = std::string(argv_[i]).substr(2);
        break;
      case 'q': optionState_[q] = true; break;
      case 'c': optionState_[c] = true; break;
      case 'h': optionState_[h] = true; break;
      case '?': optionState_[h] = true; break;
      default: break;
      }
    }
    else
    {
      patterns_.push_back(argv_[i]);
      cat_.addPattern(argv_[i]);
    }
  }
  return true;
}
Exemple #17
0
int main( int argc, char ** argv )
{
    //Check for root permissions
    if( getuid() == 0){
      qDebug() << "pc-webkitviewer must not be started as root!";
      return 1;
    }
    qDebug() << "Starting up the generic webkitviewer";
    QApplication a(argc, argv);   

    QTranslator translator;
    QLocale mylocale;
    QString langCode = mylocale.name();
    if ( ! QFile::exists( PREFIX + "/share/pcbsd/i18n/webkitviewer_" + langCode + ".qm" ) )
      langCode.truncate(langCode.indexOf("_"));
    translator.load( QString("webkitviewer_") + langCode, PREFIX + "/share/pcbsd/i18n/" );
    a.installTranslator( &translator );
    qDebug() << "Locale:" << langCode;
    QTextCodec::setCodecForLocale( QTextCodec::codecForName("UTF-8") ); //Force Utf-8 compliance
    
    bool debug = false;
    QString fileURL, title, iconpath;
    //Load the inputs
      for(int i=1; i<argc; i++){
	QString arg = QString(argv[i]);
        if(!debug){ 
	  debug = ( arg=="--debug"); 
	  if(debug){ continue; }
        }
	if(arg=="--titletext" || arg=="-t"){
	  if(i+1<argc){ i++; title = QString(argv[i]); }
	  continue;
	}
	if(arg=="--icon" || arg=="-i"){
	  if(i+1<argc){ i++; iconpath = QString(argv[i]); }
	  continue;
	}
        fileURL = QString(arg);
      }
    if(fileURL.isEmpty()){ qDebug() << "No File/URL supplied!"; showUsage(); return 1; }
    else{  
      //Add a check for relative file paths
      if(!fileURL.contains("://") && !fileURL.startsWith("/")){
        if(QFile::exists(QDir::currentPath()+"/"+fileURL)){
	  //Save and use the full path instead
	  fileURL = QDir::currentPath()+"/"+fileURL;
	}
      }
    }
      //Launch the UI
      qDebug() << "Opening:" << fileURL;
      //qDebug() << " - Inputs:" << debug << title << iconpath;
      MainUI w(debug, fileURL, title, iconpath); 
      w.show();

      a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
      return a.exec();

}
Exemple #18
0
int main(int argc, char* argv[]) {
    char* fileName;
    int errLevel;
    gridCell_t** dungeonGrid;
    room_t* rooms;
    int roomCount;
    // parse arguments
    int save = 0;
    int load = 0;
    for (int i = 0; i < argc; i++) {
        if (strcmp(argv[1], "--save") == 0) {
            save = 1;
        } else if (strcmp(argv[1], "--load") == 0) {
            load = 1;
        } else {
            showUsage(argv[0]);
            return 0;
        }
    }

    // load or generate dungeon
    if (load) {
        fileName = dungeonFileName();
        errLevel = loadDungeon(&dungeonGrid, &roomCount, &rooms, fileName);
        free(fileName);
        if (errLevel) {
            printf("Failed to load the dungeon.  Read error %d\n", errLevel);
            return -1;
        }
        populateRooms(dungeonGrid, rooms, roomCount);
    } else {
        roomCount = generateDungeon(&dungeonGrid, &rooms);
        if (roomCount < 0) {
            printf("Failed to allocate memory for the dungeon grid.\n");
            return roomCount;
        }
    }

    // print dungeon
    printRooms(roomCount, rooms);
    printGrid(dungeonGrid);

    // save dungeon
    if (save) {
        fileName = dungeonFileName();
        errLevel = saveDungeon(dungeonGrid, roomCount, rooms, fileName);
        free(fileName);
        if (errLevel) {
            printf("Failed to save the dungeon.  Save error %d\n", errLevel);
            return -1;
        }
    }

    // Clean up
    free2DGrid(dungeonGrid, HEIGHT);
    free(rooms);
    return 0;
}
Exemple #19
0
int main(int argc, char ** argv)
{
    int config_status = loadConfig(argc, argv, USAGE_CLIENT); 
    if (config_status < 0) {
        if (config_status == CONFIG_VERSION) {
            reportVersion(argv[0]);
            return 0;
        } else if (config_status == CONFIG_HELP) {
            showUsage(argv[0], USAGE_CLIENT, "[ [package.]function]");
            return 0;
        } else if (config_status != CONFIG_ERROR) {
            log(ERROR, "Unknown error reading configuration.");
        }
        // Fatal error loading config file
        return 1;
    }

    int optind = config_status;

    assert(optind <= argc);

    if (optind == (argc - 1)) {
        std::string arg(argv[optind]);
        std::string::size_type pos = arg.rfind(".");
        if (pos == std::string::npos) {
            // std::cout << "function " << arg << std::endl << std::flush;
            function = arg;
        } else {
            package = arg.substr(0, pos);
            function = arg.substr(pos + 1);
            // std::cout << "module.function " << package << "." << function << std::endl << std::flush;
        }
    } else if (optind != argc) {
        usage(argv[0]);
        return 1;
    }

    bool interactive = global_conf->findItem("", "interactive");
    int status = 0;

    init_python_api(ruleset_name, false);
    extend_client_python_api();
    new ClientPropertyManager();

    if (interactive) {
        python_prompt();
    } else {
        std::map<std::string, std::string> keywords;
        keywords["account"] = account;
        keywords["password"] = password;
        keywords["host"] = server;
        python_client_script(package, function, keywords);
    }

    shutdown_python_api();

    return status;
}
Exemple #20
0
int main(int argc, char *argv[]) {
    if (argc != 2) {
        showUsage(argc, argv, "tree directory");
        return;
    }

    myTree(argv[1], 0);
    
}
Exemple #21
0
    inline void showHelp( std::string exeName ) {
        std::string::size_type pos = exeName.find_last_of( "/\\" );
        if( pos != std::string::npos ) {
            exeName = exeName.substr( pos+1 );
        }

        std::cout << exeName << " is a CATCH host application. Options are as follows:\n\n";
        showUsage( std::cout );
    }
Exemple #22
0
void SysCacheClient::parseInputs(QStringList inputs){
  userRequest = inputs;
  if(inputs.isEmpty()){ showUsage(); }
  //Convert the user request into server request formatting
  servRequest << inputs;
  
  //Now start the connection to the server
  curSock->connectToServer("/var/run/syscache.pipe", QIODevice::ReadWrite | QIODevice::Text);
}
Exemple #23
0
MAIN(httpMain, int argc, char *argv[])
{
    MprTime     start;
    double      elapsed;

    if (mprCreate(argc, argv, MPR_USER_EVENTS_THREAD) == 0) {
        return MPR_ERR_MEMORY;
    }
    if ((app = mprAllocObj(App, manageApp)) == 0) {
        return MPR_ERR_MEMORY;
    }
    mprAddRoot(app);
    mprAddStandardSignals();

    initSettings();
    if (!parseArgs(argc, argv)) {
        showUsage();
        return MPR_ERR_BAD_ARGS;
    }
    mprSetMaxWorkers(app->workers);

#if BLD_FEATURE_SSL
    if (!mprLoadSsl(1)) {
        mprError("Can't load SSL");
        exit(1);
    }
#endif
    if (mprStart() < 0) {
        mprError("Can't start MPR for %s", mprGetAppTitle());
        exit(2);
    }
    start = mprGetTime();
    app->http = httpCreate();
    httpEaseLimits(app->http->clientLimits);

    processing();
    mprServiceEvents(-1, 0);

    if (app->benchmark) {
        elapsed = (double) (mprGetTime() - start);
        if (app->fetchCount == 0) {
            elapsed = 0;
            app->fetchCount = 1;
        }
        mprPrintf("\nRequest Count:       %13d\n", app->fetchCount);
        mprPrintf("Time elapsed:        %13.4f sec\n", elapsed / 1000.0);
        mprPrintf("Time per request:    %13.4f sec\n", elapsed / 1000.0 / app->fetchCount);
        mprPrintf("Requests per second: %13.4f\n", app->fetchCount * 1.0 / (elapsed / 1000.0));
        mprPrintf("Load threads:        %13d\n", app->loadThreads);
        mprPrintf("Worker threads:      %13d\n", app->workers);
    }
    if (!app->success && app->verbose) {
        mprError("Request failed");
    }
    return (app->success) ? 0 : 255;
}
Exemple #24
0
int main(int argc, char* argv[]) {
    if (argc == 8 && argv[1][0] == 'c') {
        compressJPEGFile(argv[2], atoi(argv[3]), atoi(argv[4]), atoi(argv[5]), atoi(argv[6]), argv[7]);
    } else if (argc == 4 && argv[1][0] == 'd') {
        decompressJPEGFile(argv[2], argv[3]);
    } else {
        showUsage(argv[0]);
    }
    return 0;
}
void Display::showResults()   // cat.build should take /s parameter
{
  /*
    s, // recurse into subdirectories
    a, // show all files
    d, // report duplicates
    f, // find text
    q, // query for text at end of execution
    c  // display commandline arguments - used for testing
    h  // show usage
  */
  if (optionEnabled(h))
  {
    showUsage();
  }
  if (optionEnabled(c))
  {
    title("Commandline arguments:");
    showCommandLine();
    std::cout << "\n";
  }
  cat_.showSummary();
  if (optionEnabled(a))
  {
    title("Show all files found:");
    cat_.showFiles();
    std::cout << "\n";
  }
  if (optionEnabled(f))
  {
    title("Show text search results:");
    std::cout << "\n  search text = \"" << searchText() << "\"";
    cat_.showSearchResults(searchText());
    std::cout << "\n";
  }
  if (optionEnabled(d))
  {
    title("Show duplicate files:");
    cat_.showDuplicates();
    std::cout << "\n";
  }
  if (optionEnabled(q))
  {
    title("Text queries:");
    std::string input;
    while (true)
    {
      std::cout << "\n  enter text string (return to quit): ";
      std::getline(std::cin, input);
      if (input.size() == 0)
        break;
      cat_.showSearchResults(input);
    }
  }
}
Exemple #26
0
void ScribusQApp::showError(QString arg)
{
	showHeader();
	if (arg.left(1) == "-" || arg.left(2) == "--") {
		std::cout << tr("Invalid argument: %1").arg(arg).toLocal8Bit().data() << std::endl;
	} else {
		std::cout << tr("File %1 does not exist, aborting.").arg(arg).toLocal8Bit().data() << std::endl;
	}
	showUsage();
	std::cout << tr("Scribus Version").toLocal8Bit().data() << " " << VERSION << std::endl;
}
Exemple #27
0
int main( int argc, char * argv[] )
{
	SP_NKLog::init4test( "testremove" );
	SP_NKLog::setLogLevel( LOG_DEBUG );

	char * host = NULL, * port = NULL;
	char * dbfile = NULL, * user = NULL, * dbname = NULL, * sql = NULL;

	extern char *optarg ;
	int c ;

	while( ( c = getopt( argc, argv, "h:p:i:u:n:ov" ) ) != EOF ) {
		switch ( c ) {
			case 'h' : host = optarg; break;
			case 'p' : port = optarg; break;
			case 'i' : dbfile = optarg; break;
			case 'u' : user = optarg; break;
			case 'n' : dbname = optarg; break;
			case 'o' : SP_NKSocket::setLogSocketDefault( 1 ); break;
			case 'v' :
			default: showUsage( argv[ 0 ] ); break;
		}
	}

	if( NULL == host || NULL == host || NULL == dbfile
			|| NULL == user || NULL == dbname ) {
		showUsage( argv[ 0 ] );
	}

	SP_NKTcpSocket socket( host, atoi( port ) );

	SP_HiveDBProtocol protocol( &socket, 0, SP_HiveDBClientConfig::eProtoBufRpc );

	int result = -1;
	int ret = protocol.remove( atoi( dbfile ), user, dbname, &result );

	printf( "remove ret %d, result %d\n", ret, result );

	return 0;
}
Exemple #28
0
bool parseCmdLine(int argc, tchar* argv[], TestSetFilters& filters)
{
	// Parse the command line.
	Core::CmdLineParser parser(s_switches, s_switches+s_switchCount);

	try
	{
		parser.parse(argc, argv);

		if (parser.isSwitchSet(VERBOSE) && parser.isSwitchSet(QUIET))
			throw CmdLineException(TXT("--quiet and --verbose are mutually exclusive"));
	}
	catch (const CmdLineException& e)
	{
		tcerr << TXT("ERROR: ") << e.twhat() << std::endl;
		showUsage(argv[0], parser);
		return false;
	}

	// Help requested?
	if (parser.isSwitchSet(HELP))
	{
		showUsage(argv[0], parser);
		return false;
	}

	// Process command line settings.
	s_verbose = parser.isSwitchSet(VERBOSE);
	s_quiet = parser.isSwitchSet(QUIET);
	s_debug = parser.isSwitchSet(DEBUG);

	// Build the test case list.
	Core::CmdLineParser::UnnamedArgs::const_iterator it = parser.getUnnamedArgs().begin();
	Core::CmdLineParser::UnnamedArgs::const_iterator end = parser.getUnnamedArgs().end();

	for (;it != end; ++it)
		filters.insert(Core::createLower(*it));

	return true;
}
Exemple #29
0
// ---------------------------------------------------------------------------
//  The parameters are:
//
//  argV[1] = The source UCM file
//  argV[2] = The path to the output file
// ---------------------------------------------------------------------------
int main(int argC, char** argV)
{
    // We have to have 3 parameters
    if (argC != 3)
    {
        showUsage();
        return 1;
    }

    // Try to open the first file for input
    gInFile = fopen(argV[1], "rt");
    if (!gInFile)
    {
        cout << "Could not find input file: " << argV[1] << endl;
        return 1;
    }

    // Try to open the second file for output (truncated)
    gOutFile = fopen(argV[2], "wt+");
    if (!gOutFile)
    {
        cout << "Could not create output file: " << argV[1] << endl;
        return 1;
    }

    //
    //  This will parse the file and load the table. It will also look for
    //  a couple of key fields in the file header and store that data into
    //  globals.
    //
    loadTable();

    // If we didn't get any table entries, then give up
    if (!gMainTableSz)
    {
        cout << "No translation table entries were found in the file" << endl;
        return 1;
    }

    //
    //  Ok, we got the data loaded. Now lets output the tables. This method
    //  spit out both tables to the output file, in a format ready to be
    //  incorporated directly into the source code.
    //
    formatSBTables();

    // Close our files
    fclose(gInFile);
    fclose(gOutFile);

    return 0;
}
//--------------------------------------------------------------------
// getKeyboardOrder
//--------------------------------------------------------------------
bool getKeyboardOrder(Order &order)
{
    order.reset();
    char rep;
    read(0,&rep,1);
  //  printf("read=%d\n", rep);
    switch (rep) {
        // motor
    case 27 : 
        read(0,&rep,1); 
        read(0,&rep,1);
        switch (rep) {
	case 'A' : handleForward(order); break;
	case 'B' : handleBackward(order); break;
	case 'D' : handleLeft(order); break;
	case 'C' : handleRight(order); break;
        }
        break;
    case '8' : handleForward(order); break;
    case '2' : handleBackward(order); break;
    case '4' : handleLeft(order); break;
    case '6' : handleRight(order); break;
        // emergency stop
    case '5' :
    case ' ' : 
        setEmergencyStopOrder(order);
        break; 
    case 'r' :
    case 'R' :    
	order.resetRobotPos=true;
        order.motorReset=1;
        order.speedLeft=0;
        order.speedRight=0;
        break;  
    case 'h' :
    case 'H' : 
        showUsage();
        break;   
    case 'q': 
    case 'Q': 
    case '-':
        quitApplication = true;
        break;
    default:
        break;
    }
    checkMotorOrder(order);
    return true;
}