• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PrintHelp函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PrintHelp函数的典型用法代码示例。如果您正苦于以下问题:C++ PrintHelp函数的具体用法?C++ PrintHelp怎么用?C++ PrintHelp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PrintHelp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: GenericAgentConfigNewDefault

static GenericAgentConfig *CheckOpts(EvalContext *ctx, int argc, char **argv)
{
    extern char *optarg;
    int optindex = 0;
    int c;
    char ld_library_path[CF_BUFSIZE];
    GenericAgentConfig *config = GenericAgentConfigNewDefault(AGENT_TYPE_EXECUTOR);

    while ((c = getopt_long(argc, argv, "dvnKIf:D:N:VxL:hFOV1gMWlC::", OPTIONS, &optindex)) != EOF)
    {
        switch ((char) c)
        {
        case 'l':
            LEGACY_OUTPUT = true;
            break;

        case 'f':

            if (optarg && strlen(optarg) < 5)
            {
                Log(LOG_LEVEL_ERR, " -f used but argument '%s' incorrect", optarg);
                exit(EXIT_FAILURE);
            }

            GenericAgentConfigSetInputFile(config, GetWorkDir(), optarg);
            MINUSF = true;
            break;

        case 'd':
            LogSetGlobalLevel(LOG_LEVEL_DEBUG);
            break;

        case 'K':
            IGNORELOCK = true;
            break;

        case 'D':
            config->heap_soft = StringSetFromString(optarg, ',');
            break;

        case 'N':
            config->heap_negated = StringSetFromString(optarg, ',');
            break;

        case 'I':
            LogSetGlobalLevel(LOG_LEVEL_INFO);
            break;

        case 'v':
            LogSetGlobalLevel(LOG_LEVEL_VERBOSE);
            NO_FORK = true; // TODO: really?
            break;

        case 'n':
            DONTDO = true;
            IGNORELOCK = true;
            EvalContextHeapAddHard(ctx, "opt_dry_run");
            break;

        case 'L':
            snprintf(ld_library_path, CF_BUFSIZE - 1, "LD_LIBRARY_PATH=%s", optarg);
            if (putenv(xstrdup(ld_library_path)) != 0)
            {
            }
            break;

        case 'W':
            WINSERVICE = false;
            break;

        case 'F':
            NO_FORK = true;
            break;

        case 'O':
            ONCE = true;
            NO_FORK = true;
            break;

        case 'V':
            PrintVersion();
            exit(0);

        case 'h':
            PrintHelp("cf-execd", OPTIONS, HINTS, true);
            exit(0);

        case 'M':
            {
                Writer *out = FileWriter(stdout);
                ManPageWrite(out, "cf-execd", time(NULL),
                             CF_EXECD_SHORT_DESCRIPTION,
                             CF_EXECD_MANPAGE_LONG_DESCRIPTION,
                             OPTIONS, HINTS,
                             true);
                FileWriterDetach(out);
                exit(EXIT_SUCCESS);
            }

        case 'x':
//.........这里部分代码省略.........
开发者ID:mvpel,项目名称:core,代码行数:101,代码来源:cf-execd.c


示例2: main

/*************************************************************************************************
 *************************************************************************************************
 *
 *  Start of Main Function
 *
 *************************************************************************************************
 ************************************************************************************************/
int main (int argc, char *argv[])
{
  init_salute();

  ofstream null_ostream("/dev/null"); // must stay live for entire scope, or crash when writing
  TheSilenceOfTheArmadillos(null_ostream);

  TrackProgress my_progress;  
  DumpStartingStateOfProgram (argc,argv,my_progress);

  if(argc < 2)
  {
      PrintHelp();
  }

  for(int i = 1; i < argc; ++i)
  {
	  string s = argv[i];
	  if(s == "-" || s == "--")
	  {
	      cerr << "ERROR: command line input \"-\" must be followed by a short option name (a letter) and \"--\" must be followed by a long option name." << endl; 
		  exit ( EXIT_FAILURE );
	  }
	  else if(s == "-?" || s == "-h" || s == "--help")
	  {
	      PrintHelp();
	  }
  }

  ValidateOpts validater;
  validater.Validate(argc, argv);

  char** argv2 = new char*[argc];
  int datind = TrapAndDeprecateOldArgs(argc, argv, argv2);

  OptArgs opts;
  opts.ParseCmdLine(argc, (const char**)argv2);

  for(int k = 0; k < argc ; ++k)
  {
	  delete [] argv2[k];
  }
  delete [] argv2;
   
  Json::Value json_params;
  CommandLineOpts inception_state;
  inception_state.SetOpts(opts, json_params);

  if(datind < 0) // there is no "--dat-source-directory"
  {
	  inception_state.sys_context.dat_source_directory = argv[argc - 1];
	  cout << "dat_source_directory = " << inception_state.sys_context.dat_source_directory << endl;
  }

  inception_state.PostProcessArgs(opts);

  SeqListClass my_keys;
  ImageSpecClass my_image_spec;
  SlicedPrequel my_prequel_setup;

  SetUpOrLoadInitialState(inception_state, my_keys, my_progress, my_image_spec, my_prequel_setup);
  
  // Start logging process parameters & timing now that we have somewhere to log
  my_progress.InitFPLog(inception_state);

  // Write processParameters.parse file now that processing is about to begin
  my_progress.WriteProcessParameters(inception_state);

  // Do background model
  RealImagesToWells ( opts, inception_state, my_keys, my_progress, my_image_spec, my_prequel_setup);

  my_progress.ReportState ("Analysis (wells file only) Complete");

  exit (ExitCode::GetExitCode());
}
开发者ID:Brainiarc7,项目名称:TS,代码行数:82,代码来源:Analysis.cpp


示例3: main

int main( int argc, char *argv[])
{
double (* f)();
void *MsgCtx = 0; /* This is the context of the message-passing operation */
void *outctx;
int  reps,len,error_flag;
double t;
int  first,last,incr, svals[3];
char     units[32];         /* Name of units of length */

MPI_Init( &argc, &argv );
MPI_Comm_size( MPI_COMM_WORLD, &__NUMNODES );
MPI_Comm_rank( MPI_COMM_WORLD, &__MYPROCID );
;
strcpy( units, "" );

if (SYArgHasName( &argc, argv, 1, "-help" )) {
  return PrintHelp( argv );
  }

if (__NUMNODES < 2) {
    fprintf( stderr, "Must run goptest with at least 2 nodes\n" );
    return 1;
    }

/* Get the output context */
outctx = SetupGraph( &argc, argv );
if (SYArgHasName( &argc, argv, 1, "-noinfo" ))    doinfo    = 0;
if (SYArgHasName( &argc, argv, 1, "-nohead" ))    doheader  = 0;
if (SYArgHasName( &argc, argv, 1, "-notail" ))    dotail    = 0;

reps          = DEFAULT_REPS;
error_flag    = 0;
if (SYArgHasName( &argc, argv, 0, "-sync") ) {
    svals[0] = svals[1] = svals[2] = 0;
    }
else {
    /* We use fewer values because we are generating them on the same line. */
    svals[0]      = 0;
    svals[1]      = 1024;
    svals[2]      = 256;
    }

SYArgGetIntVec( &argc, argv, 1, "-size", 3, svals );
nsizes = SYArgGetIntList( &argc, argv, 1, "-sizelist", MAX_SIZE_LIST, 
                          sizelist );
/* We ALWAYS use sizelist */
if (nsizes == 0) {
    /* Generate the size list from the svals list */
    sizelist[0] = svals[0];
    for (nsizes=1; sizelist[nsizes-1] < svals[1] && nsizes<MAX_SIZE_LIST; 
	 nsizes++) {
	sizelist[nsizes] = sizelist[nsizes-1] + svals[2];
	}
    if (sizelist[nsizes] > svals[1]) nsizes--;
    }

SYArgGetInt(    &argc, argv, 1, "-reps", &reps );
if (SYArgHasName( &argc, argv, 1, "-autoreps" ))  AutoReps  = 1;
if (SYArgGetDouble( &argc, argv, 1, "-tgoal", &Tgoal )) {
    AutoReps = 1;
    if (TgoalMin > 0.1 * Tgoal) TgoalMin = 0.1 * Tgoal;
    }
SYArgGetDouble( &argc, argv, 1, "-rthresh", &repsThresh );

f      = GetGOPFunction( &argc, argv, test_name, units );
MsgCtx = GOPInit( &argc, argv );
first = svals[0];
last  = svals[1];
incr  = svals[2];
if (incr == 0) incr = 1;

/*
   Finally, we are ready to run the tests.  We want to report times as
   the times for a single link, and rates as the aggregate rate.
   To do this, we need to know how to scale both the times and the rates.

   Times: scaled by the number of one-way trips measured by the base testing
   code.  This is often 2 trips, or a scaling of 1/2.

   Rates: scaled by the number of simultaneous participants (as well as
   the scaling in times).  Compute the rates based on the updated time, 
   then multiply by the number of participants.  Note that, for a single
   sender, time and rate are inversely proportional (that is, if TimeScale 
   is 0.5, RateScale is 2.0).

 */

if (doinfo && doheader &&__MYPROCID == 0) {
    HeaderForGopGraph( outctx, test_name, (char *)0, units );
    }
time_function(reps,first,last,incr,f,outctx,MsgCtx);

/* 
   Generate the "end of page".  This allows multiple graphs on the
   same plot 
 */
if (doinfo && dotail && __MYPROCID == 0) 
    EndPageGraph( outctx );

//.........这里部分代码省略.........
开发者ID:MartinLidh,项目名称:tddc78,代码行数:101,代码来源:goptest.c


示例4: PrintHelp

void XYUVHeader::Run(const ::options & options) {

    // If help has been requested, print it and quit.
    if (options.print_help) {
        PrintHelp();
        return;
    }

    // Otherwise do something useful.
#ifdef INSTALL_FORMATS_PATH
    // Load base formats from installation path
    config_manager_.load_configurations(INSTALL_FORMATS_PATH);
#endif

    // Load all additional formats supplied on the command line.
    for (const auto & path : options.additional_config_directories) {
        config_manager_.load_configurations(path);
    }

    // If a list of all formats has been requested, print it and quit.
    if (options.list_all_formats) {
        PrintAllFormats();
        return;
    }

    // Try to aquire each output stream.
    bool detect_concatinate = options.concatinate;
    std::vector<std::string> output_names;

    if (options.writeout) {
        // Make a set of output names to do argument validation.
        std::unordered_set<std::string> out_name_set;

        if ( options.output_name.size() == 0 ) {
            // If concatinating, use first file name as output.
            if (detect_concatinate) {
                std::string out_path = strip_suffix(options.input_files[0]) + ".xyuv";
                out_name_set.emplace(out_path);
                output_names.emplace_back(out_path);
            }
            else {
                for (const auto & in_file : options.input_files ) {
                    std::string out_path = strip_suffix(in_file) + ".xyuv";

                    out_name_set.insert(out_path);
                    output_names.emplace_back(out_path);
                }
            }
        }
        else {
            for (const auto & out_path : options.output_name ) {
                out_name_set.insert(out_path);
                output_names.emplace_back(out_path);
            }
        }

        // Check that no two output files overwrite one another.
        if (out_name_set.size() != output_names.size()) {
            throw std::invalid_argument("The same output name is given more than once. This is illegal for one invocation of the program.");
        }

        // Check that no input file is the same as an output file.
        // We don't account for relative paths etc here, but we won't care for now.
        for (const auto & in_path : options.input_files) {
            if (out_name_set.find(in_path) != out_name_set.end()) {
                throw std::invalid_argument("File '" + in_path + "' given as both an input and an output file, this is illegal.");
            }
        }

        // Check that the number of output files matches the number of input files
        // or one.
        if (output_names.size() != 1 && output_names.size() != options.input_files.size() ) {
            throw std::invalid_argument("If supplied, the number of output files must exactly match the number of input files or one.");
        }

        if (output_names.size() == 1 && options.input_files.size() > 1) {
            detect_concatinate = true;
        }
    }

    // Check validity of formats:
    std::vector<xyuv::format_template> format_templates;
    std::vector<xyuv::chroma_siting> sitings;
    std::vector<xyuv::conversion_matrix> matrices;

    for (const auto & format_template : options.output_formats ) {
        try {
            // Try to load the format-template from file.
            format_templates.push_back(xyuv::config_manager::load_format_template(format_template));
        } catch (std::runtime_error & e) {
            try {
                // If that failed look it up in the config manager.
                format_templates.push_back(config_manager_.get_format_template(format_template));
            } catch (std::exception e2) {
                std::string err_msg = std::string("Could not load format template ") + format_template +
                        ": " + e.what() + " and " + e2.what() + ". Please check the spelling of the argument.";
                throw std::invalid_argument(std::string(err_msg));
            }
        }
    }
//.........这里部分代码省略.........
开发者ID:Catuna,项目名称:xyuv,代码行数:101,代码来源:xyuv_header_run.cpp


示例5: RNETA_ParseCommand

uint8_t RNETA_ParseCommand(const unsigned char *cmd, bool *handled, const CLS1_StdIOType *io) {
  uint8_t res = ERR_OK;
  const uint8_t *p;
  uint16_t val16;
  uint8_t val8;

  if (UTIL1_strcmp((char*)cmd, (char*)CLS1_CMD_HELP)==0 || UTIL1_strcmp((char*)cmd, (char*)"rapp help")==0) {
    PrintHelp(io);
    *handled = TRUE;
  } else if (UTIL1_strcmp((char*)cmd, (char*)CLS1_CMD_STATUS)==0 || UTIL1_strcmp((char*)cmd, (char*)"rapp status")==0) {
    *handled = TRUE;
    return PrintStatus(io);
  } else if (UTIL1_strncmp((char*)cmd, (char*)"rapp saddr", sizeof("rapp saddr")-1)==0) {
    p = cmd + sizeof("rapp saddr")-1;
    *handled = TRUE;
    if (UTIL1_ScanHex16uNumber(&p, &val16)==ERR_OK) {
      (void)RNWK_SetThisNodeAddr((RNWK_ShortAddrType)val16);
    } else {
      CLS1_SendStr((unsigned char*)"ERR: wrong address\r\n", io->stdErr);
      return ERR_FAILED;
    }
  } else if (UTIL1_strncmp((char*)cmd, (char*)"rapp send val", sizeof("rapp send val")-1)==0) {
    p = cmd + sizeof("rapp send val")-1;
    *handled = TRUE;
    if (UTIL1_ScanDecimal8uNumber(&p, &val8)==ERR_OK) {
      (void)RAPP_SendPayloadDataBlock(&val8, sizeof(val8), (uint8_t)RAPP_MSG_TYPE_DATA, APP_dstAddr, RPHY_PACKET_FLAGS_NONE); /* only send low byte */
    } else {
      CLS1_SendStr((unsigned char*)"ERR: wrong number format\r\n", io->stdErr);
      return ERR_FAILED;
    }
  } else if (UTIL1_strncmp((char*)cmd, (char*)"rapp daddr", sizeof("rapp daddr")-1)==0) {
    p = cmd + sizeof("rapp daddr")-1;
    *handled = TRUE;
    if (UTIL1_ScanHex16uNumber(&p, &val16)==ERR_OK) {
      APP_dstAddr = val16;
    } else {
      CLS1_SendStr((unsigned char*)"ERR: wrong address\r\n", io->stdErr);
      return ERR_FAILED;
    }
#if RNET_CONFIG_REMOTE_STDIO
  } else if (UTIL1_strncmp((char*)cmd, (char*)"rapp send", sizeof("rapp send")-1)==0) {
    unsigned char buf[32];
    RSTDIO_QueueType queue;
    
    if (UTIL1_strncmp((char*)cmd, (char*)"rapp send in", sizeof("rapp send in")-1)==0) {
      queue = RSTDIO_QUEUE_TX_IN;
      cmd += sizeof("rapp send in");
    } else if (UTIL1_strncmp((char*)cmd, (char*)"rapp send out", sizeof("rapp send out")-1)==0) {
      queue = RSTDIO_QUEUE_TX_OUT;      
      cmd += sizeof("rapp send out");
    } else if (UTIL1_strncmp((char*)cmd, (char*)"rapp send err", sizeof("rapp send err")-1)==0) {
      queue = RSTDIO_QUEUE_TX_ERR;      
      cmd += sizeof("rapp send err");
    } else {
      return ERR_OK; /* not handled */
    }
    UTIL1_strcpy(buf, sizeof(buf), cmd);
    UTIL1_chcat(buf, sizeof(buf), '\n');
    buf[sizeof(buf)-2] = '\n'; /* have a '\n' in any case */
    if (RSTDIO_SendToTxStdio(queue, buf, UTIL1_strlen((char*)buf))!=ERR_OK) {
      CLS1_SendStr((unsigned char*)"failed!\r\n", io->stdErr);
    }
    *handled = TRUE;
#endif
  }
  return res;
}
开发者ID:ADeadCat,项目名称:mcuoneclipse,代码行数:67,代码来源:RNet_App.c


示例6: PrintHelpAndExit

// ------------------------------------------------------------------------------------------------
int PrintHelpAndExit(int _argNum, int _argc, char* _argv[], Options* _outOptions, size_t _byteOffset)
{
    PrintHelp(0);
    return 1;
}
开发者ID:ChickenEggSolutions,项目名称:apitest,代码行数:6,代码来源:options.cpp


示例7: if


//.........这里部分代码省略.........
        }
        else if (!strcmp(arg, "--swapInterval"))
        {
            args.swapInterval = atoi(argv[++i]);
        }
        else if (!strcmp(arg, "--start"))
        {
            args.start = atoi(argv[++i]);
        }
        else if (!strcmp(arg, "--end"))
        {
            args.end = atoi(argv[++i]);
        }
        else if (!strcmp(arg, "--runFrames"))
        {
            args.runFrames = atoi(argv[++i]);
        }
        else if (!strcmp(arg, "--dumpDraw"))
        {
            args.dumpDraw = TCG_TRUE;
        }
        else if (!strcmp(arg, "--dumpFrame"))
        {
            args.dumpFrame = TCG_TRUE;
        }
        else if (!strcmp(arg, "--finish"))
        {
            args.finish = TCG_TRUE;
        }
        else if (!strcmp(arg, "--swapbuf"))
        {
            args.swapbuf= TCG_TRUE;
        }
        else if (!strcmp(arg, "--rendertime"))
        {
            args.renderingtime= TCG_TRUE;
        }
        else if (!strcmp(arg, "--zoom"))
        {
            args.zoom= TCG_TRUE;
        }
        else if (!strcmp(arg, "--analyze"))
        {
            args.analyze = TCG_TRUE;
        }
        else if (!strcmp(arg, "--default-context"))
        {
            args.default_context= TCG_TRUE;
        }
        else if (!strcmp(arg, "--fps"))
        {
            if (!(i + 1 < argc))
            {
                PrintHelp();
                return TCG_FALSE;
            }
            if (!from_string<TCGint>(args.fpsinterval, argv[i+1]) || args.fpsinterval < 0)
            {
                TCGLOG(TCG_ERROR, TCG_CLIENT_OS, "%s is not a valid fps interval\n\n", argv[i+1]);
                return TCG_FALSE;
            }
            ++i;
        }
        else if (!strcmp(arg, "--config"))
        {
            if (!(i + 1 < argc))
            {
                PrintHelp();
                return TCG_FALSE;
            }
            if (!from_string<EGLint>(args.configid, argv[i+1]))
            {
                TCGLOG(TCG_ERROR, TCG_CLIENT_OS, "'%s' is not a valid config id\n\n.", argv[i+1]);
                return TCG_FALSE;
            }
            ++i;
        }
        else if (!strcmp(arg, "--patchid"))
        {
            if (!(i + 1 < argc))
            {
                PrintHelp();
                return TCG_FALSE;
            }
            if (!from_string<EGLenum>(args.patchid, argv[i+1]))
            {
                TCGLOG(TCG_ERROR, TCG_CLIENT_OS, "'%s' is not a valid patch id\n\n.", argv[i+1]);
                return TCG_FALSE;
            }
            ++i;
        }
        else if (!strcmp(arg, "--help")||!strcmp(arg, "-h")||(arg[0] == '-'))
        {
            PrintHelp();
            return TCG_FALSE;
        }
    }

    return TCG_TRUE;
}
开发者ID:hyyh619,项目名称:GLESAPIAnalyzer,代码行数:101,代码来源:TcgMacOSXClient.cpp


示例8: main

int main (int argc, char *argv[])
{
#ifndef _DEBUG
	if(argc == 1)
	{
		PrintHelp();
		return 0;
	}
	if(argc != 4)
	{
		printf("Too few arguments provided.  Specify a patch file to create and the updated and original files for comparison.");
		PrintHelp();
		return 0;
	}
#endif

	FILE *updated, *original, *patch;
#if _DEBUG
	updated = fopen("UWASA1patched.BIN", "rb");
#else
	updated = fopen(argv[2], "rb");
#endif
	if(!updated)
	{
		printf("Error opening updated file %s", argv[2]);
		return 0;
	}

#if _DEBUG
	original = fopen("UWASA1.BIN", "rb");
#else
	original = fopen(argv[3], "rb");
#endif
	if(!original)
	{
		printf("Error opening original file %s", argv[3]);
		return 0;
	}

#if _DEBUG
	patch = fopen("uwasa_1.ppf", "wb");
#else
	patch = fopen(argv[1], "wb");
#endif
	if(!patch)
	{
		printf("Error opening patch file %s", argv[1]);
		return 0;
	}

	PatchHeader header;
	header.Serialize(patch);

	PatchData pd;
	u8 updbyte, origbyte;
	fread(&updbyte, 1, 1, updated);
	fread(&origbyte, 1, 1, original);
	while(!feof(updated))
	{
		if(!feof(original))
		{
			if(origbyte != updbyte)
			{
				if(pd.command != 0)
				{
					printf("Critical Error:  Difference found, but command is add.\n");
					return 0;
				}
				if(pd.size == 0) pd.offset = ftell(original) - 1;
				pd.data[pd.size] = updbyte;
				pd.size++;
				if(pd.size == PATCH_DATA_MAXSIZE)
				{
					pd.Serialize(patch);
					pd.Reset();
				}
			}
			else if(pd.size > 0)
			{
				pd.Serialize(patch);
				pd.Reset();
			}
			fread(&origbyte, 1, 1, original);
			fread(&updbyte, 1, 1, updated);
		}
		else
		{
			// process remainder of updated data as additions
			if(pd.size > 0)
			{
				pd.Serialize(patch);
			}
			pd.Reset();
			pd.command = PATCH_CMD_ADD;

			while(!feof(updated))
			{
				pd.data[pd.size] = updbyte;
				pd.size++;
				if(pd.size == PATCH_DATA_MAXSIZE)
//.........这里部分代码省略.........
开发者ID:pyriell,项目名称:gs2-bugfixes,代码行数:101,代码来源:ppfmaker.cpp


示例9: GenericAgentConfigNewDefault

GenericAgentConfig *CheckOpts(int argc, char **argv)
{
    extern char *optarg;
    char ld_library_path[CF_BUFSIZE];
    int optindex = 0;
    int c;
    GenericAgentConfig *config = GenericAgentConfigNewDefault(AGENT_TYPE_SERVER);

    while ((c = getopt_long(argc, argv, "dvIKf:D:N:VSxLFMhAlC::", OPTIONS, &optindex)) != EOF)
    {
        switch ((char) c)
        {
        case 'l':
            LEGACY_OUTPUT = true;
            break;

        case 'f':

            if (optarg && (strlen(optarg) < 5))
            {
                Log(LOG_LEVEL_ERR, " -f used but argument '%s' incorrect", optarg);
                exit(EXIT_FAILURE);
            }

            GenericAgentConfigSetInputFile(config, GetWorkDir(), optarg);
            MINUSF = true;
            break;

        case 'd':
            LogSetGlobalLevel(LOG_LEVEL_DEBUG);
            NO_FORK = true;

        case 'K':
            IGNORELOCK = true;
            break;

        case 'D':
            config->heap_soft = StringSetFromString(optarg, ',');
            break;

        case 'N':
            config->heap_negated = StringSetFromString(optarg, ',');
            break;

        case 'I':
            LogSetGlobalLevel(LOG_LEVEL_INFO);
            break;

        case 'v':
            LogSetGlobalLevel(LOG_LEVEL_VERBOSE);
            NO_FORK = true;
            break;

        case 'F':
            NO_FORK = true;
            break;

        case 'L':
            Log(LOG_LEVEL_VERBOSE, "Setting LD_LIBRARY_PATH to '%s'", optarg);
            snprintf(ld_library_path, CF_BUFSIZE - 1, "LD_LIBRARY_PATH=%s", optarg);
            putenv(ld_library_path);
            break;

        case 'V':
            PrintVersion();
            exit(0);

        case 'h':
            PrintHelp("cf-serverd", OPTIONS, HINTS, true);
            exit(0);

        case 'M':
            {
                Writer *out = FileWriter(stdout);
                ManPageWrite(out, "cf-serverd", time(NULL),
                             CF_SERVERD_SHORT_DESCRIPTION,
                             CF_SERVERD_MANPAGE_LONG_DESCRIPTION,
                             OPTIONS, HINTS,
                             true);
                FileWriterDetach(out);
                exit(EXIT_SUCCESS);
            }

        case 'x':
            Log(LOG_LEVEL_ERR, "Self-diagnostic functionality is retired.");
            exit(0);
        case 'A':
#ifdef HAVE_AVAHI_CLIENT_CLIENT_H
#ifdef HAVE_AVAHI_COMMON_ADDRESS_H
            Log(LOG_LEVEL_NOTICE, "Generating Avahi configuration file.");
            if (GenerateAvahiConfig("/etc/avahi/services/cfengine-hub.service") != 0)
            {
                exit(1);
            }
            cf_popen("/etc/init.d/avahi-daemon restart", "r", true);
            Log(LOG_LEVEL_NOTICE, "Avahi configuration file generated successfuly.");
            exit(0);
#endif
#endif
            Log(LOG_LEVEL_ERR, "Generating avahi configuration can only be done when avahi-daemon and libavahi are installed on the machine.");
//.........这里部分代码省略.........
开发者ID:JarleB,项目名称:core,代码行数:101,代码来源:cf-serverd-functions.c


示例10: _LIT

// ---------------------------------------------------------
// CPosPSYListView::HandleKeyEventL
// 
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CPosPSYListView::HandleKeyEventL(
    TKeyCode aKey)
    {
    _LIT(KAlreadyRunning, "\r\nAlready running.");
	_LIT(KNoTestsRunning, "\r\nNo test running.");

	if (aKey == EKeyRightArrow)
        {
        iViewManager->SwitchViewL(KPSYSettingsView);
        }
	else if (IsHelpRequested(aKey))
        {
        PrintHelp();
        }

    if (iReadBuf.Count() < KMaxBufSize)
        {
        if (IsNumeric(aKey))
   		    {
			if (iReadBuf.Count() == 0) 
				{
				_LIT(KMsg, "\r\nPSY: ");
				iConsole->Printf(KMsg);
				}
			_LIT(KKey, "%c");
			TBuf<10> buf;
			buf.Format(KKey, aKey);
			iConsole->Printf(buf);
            iReadBuf.Append((static_cast<TInt> (aKey)) - '0');
   		    }
        else if ((aKey == 'R') || (aKey == 'r'))
            {
			if (iTestHandler->TestsRunning())
				{
				iConsole->Printf(KAlreadyRunning);				
				}
			else
				{
				iTestHandler->StartPSYTesterL(KTestAllPSYs);
				}
			}
		else if ((aKey == 'C') || (aKey == 'c'))
   		    {
			if (iTestHandler->TestsRunning())
				{
				iTestHandler->Cancel();
				_LIT(KMsg, "\r\nTests canceled.");
				iConsole->Printf(KMsg);
				}
			else 
				{
				iConsole->Printf(KNoTestsRunning);				
				}
			}
        else if (aKey == 'L' ||			// "L"
				 aKey == 'l')			// "l"
            {
            iCurrentIndex = 0;
            iTestHandler->UpdatePSYListL();
            iConsole->ClearScreen();
            ListPSYs(KListStart);
            }
        else if (aKey == 'X' ||	
				 aKey == 'x' ||
				 aKey == EKeyDevice1)		// right softkey (S60)
            {
            CActiveScheduler::Stop();
			}
        else if (aKey == 'F' ||       // "F"
				 aKey == 'f' ||		  // "f"
				 aKey == EKeyUpArrow) // joy-stick up (S60)
            {
            iConsole->ClearScreen();
            ListPSYs(KListPrevious);
			}
        else if (aKey == 'N' ||			// "N"
				 aKey == 'n' ||			// "n"
				 aKey == EKeyDownArrow) // joy-stick down (S60)
            {
            iConsole->ClearScreen();
            ListPSYs(KListNext);
			}
        else if (aKey == 'U' ||			// "U"
				 aKey == 'u')			// "u"
            {
            iReadBuf.Reset();
            iCurrentIndex = 0;
            iTestHandler->UpdatePSYListL();
            iConsole->ClearScreen();
            ListPSYs(KListStart);
			}
		else if (aKey == EKeyEnter || // enter
				 aKey == EKeyDevice3) // stick down (S60)
            {
//.........这里部分代码省略.........
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:101,代码来源:epos_cpospsylistview.cpp


示例11: main

int main(int argc, char* argv[]) {
  int retval = 0;
  int i;

  char* progname = strrchr(argv[0], '/');
  if (progname)
    progname++;
  else
    progname = argv[0];

  if (VbArchInit()) {
    fprintf(stderr, "Failed to initialize\n");
    return -1;
  }

  /* If no args specified, print all params */
  if (argc == 1)
    return PrintAllParams(0);
  /* --all or -a prints all params including normally hidden ones */
  if (!strcasecmp(argv[1], "--all") || !strcmp(argv[1], "-a"))
    return PrintAllParams(1);

  /* Print help if needed */
  if (!strcasecmp(argv[1], "-h") || !strcmp(argv[1], "-?")) {
    PrintHelp(progname);
    return 0;
  }

  /* Otherwise, loop through params and get/set them */
  for (i = 1; i < argc && retval == 0; i++) {
    char* has_set = strchr(argv[i], '=');
    char* has_expect = strchr(argv[i], '?');
    char* name = strtok(argv[i], "=?");
    char* value = strtok(NULL, "=?");
    const Param* p;

    /* Make sure args are well-formed. '' or '=foo' or '?foo' not allowed. */
    if (!name || has_set == argv[i] || has_expect == argv[i]) {
      fprintf(stderr, "Poorly formed parameter\n");
      PrintHelp(progname);
      return 1;
    }
    if (!value)
      value=""; /* Allow setting/checking an empty string ('foo=' or 'foo?') */
    if (has_set && has_expect) {
      fprintf(stderr, "Use either = or ? in a parameter, but not both.\n");
      PrintHelp(progname);
      return 1;
    }

    /* Find the parameter */
    p = FindParam(name);
    if (!p) {
      fprintf(stderr, "Invalid parameter name: %s\n", name);
      PrintHelp(progname);
      return 1;
    }

    if (i > 1)
      printf(" ");  /* Output params space-delimited */
    if (has_set)
      retval = SetParam(p, value);
    else if (has_expect)
      retval = CheckParam(p, value);
    else
      retval = PrintParam(p);
  }

  return retval;
}
开发者ID:ccaapton,项目名称:vboot_reference,代码行数:70,代码来源:crossystem.c


示例12: MCP4728_ParseCommand

byte MCP4728_ParseCommand(const unsigned char *cmd, bool *handled, const CLS1_StdIOType *io) {
  const unsigned char *p;

  if (UTIL1_strcmp((char*)cmd, CLS1_CMD_HELP)==0 || UTIL1_strcmp((char*)cmd, "MCP4728 help")==0) {
    *handled = TRUE;
    return PrintHelp(io);
  } else if ((UTIL1_strcmp((char*)cmd, CLS1_CMD_STATUS)==0) || (UTIL1_strcmp((char*)cmd, "MCP4728 status")==0)) {
    *handled = TRUE;
    return PrintStatus(io);
  } else if (UTIL1_strcmp((char*)cmd, "MCP4728 reset")==0) {
    *handled = TRUE;
    if (MCP4728_Reset()!=ERR_OK) {
      return ERR_FAILED;
    } else {
      return ERR_OK;
    }
  } else if (UTIL1_strcmp((char*)cmd, "MCP4728 wakeup")==0) {
    *handled = TRUE;
    if (MCP4728_Wakeup()!=ERR_OK) {
      return ERR_FAILED;
    } else {
      return ERR_OK;
    }
  } else if (UTIL1_strcmp((char*)cmd, "MCP4728 update")==0) {
    *handled = TRUE;
    if (MCP4728_Update()!=ERR_OK) {
      return ERR_FAILED;
    } else {
      return ERR_OK;
    }
  } else if (UTIL1_strncmp((char*)cmd, "MCP4728 fastwrite all ", sizeof("MCP4728 fastwrite all ")-1)==0) {
    uint16_t dac[4];
    uint8_t pd[4];
    int i;
    
    *handled = TRUE;
    p = cmd+sizeof("MCP4728 fastwrite all ")-1;
    for(i=0;i<4;i++) { /* init */
      dac[i] = 0;
      pd[i] = 0;
    }
    for(i=0;i<4;i++) {
      if (UTIL1_ScanHex16uNumber(&p, &dac[i])!=ERR_OK) {
        break;
      }
      dac[i] &= MCP4728_MAX_DAC_VAL; /* ensure it is 12 bits */
    }
    if (i!=4) {
      CLS1_SendStr((unsigned char*)"**** Not enough values, 4 expected!\r\n", io->stdErr);
      return ERR_FAILED;
    }
    if (MCP4728_FastWriteAllDAC(dac, sizeof(dac), pd, sizeof(pd))!=ERR_OK) {
      CLS1_SendStr((unsigned char*)"**** FastWrite failed.\r\n", io->stdErr);
      return ERR_FAILED;
    } else {
      return ERR_OK;
    }
  } else if (UTIL1_strncmp((char*)cmd, "MCP4728 fastwrite ", sizeof("MCP4728 fastwrite ")-1)==0) {
    /* e.g. MCP4728 fastwrite 2 0x512 */
    uint16_t dac=0;
    uint8_t channel=0;

    *handled = TRUE;
    p = cmd+sizeof("MCP4728 fastwrite ")-1;
    if (UTIL1_ScanDecimal8uNumber(&p, &channel)!=ERR_OK || channel>3) {
      CLS1_SendStr((unsigned char*)"**** error parsing channel, must be 0, 1, 2 or 3!\r\n", io->stdErr);
      return ERR_FAILED;
    }
    if (UTIL1_ScanHex16uNumber(&p, &dac)!=ERR_OK || dac>MCP4728_MAX_DAC_VAL) {
      CLS1_SendStr((unsigned char*)"**** error parsing 12bit hex value, must start with 0x!\r\n", io->stdErr);
      return ERR_FAILED;
    }
    dac &= MCP4728_MAX_DAC_VAL; /* ensure it is 12 bits */
    if (MCP4728_FastWriteDAC(channel, dac)!=ERR_OK) {
      CLS1_SendStr((unsigned char*)"**** Write channel DAC failed!\r\n", io->stdErr);
      return ERR_FAILED;
    } else {
      return ERR_OK;
    }
  } else if (UTIL1_strncmp((char*)cmd, "MCP4728 write ", sizeof("MCP4728 write ")-1)==0) {
    uint16_t dac;
    uint8_t ch, res;
    
    *handled = TRUE;
    res = ERR_OK;
    p = cmd+sizeof("MCP4728 write ")-1;
    if (UTIL1_ScanDecimal8uNumber(&p, &ch)!=ERR_OK || ch>3) {
      CLS1_SendStr((unsigned char*)"**** Failed reading channel. Must be 0, 1, 2 or 3\r\n", io->stdErr);
      res = ERR_FAILED;
    } else {
      if (UTIL1_ScanHex16uNumber(&p, &dac)!=ERR_OK) {
        CLS1_SendStr((unsigned char*)"**** Failed DAC value, must start with 0x\r\n", io->stdErr);
        res = ERR_FAILED;
      } else {
        if (MCP4728_WriteDACandEE(ch, dac)!=ERR_OK) {
          CLS1_SendStr((unsigned char*)"**** Write failed.\r\n", io->stdErr);
          res = ERR_FAILED;
        }
      }
    }
//.........这里部分代码省略.........
开发者ID:fmario,项目名称:intro_sumo,代码行数:101,代码来源:MCP4728.c


示例13: main

//#define PROFILE
int main(int argc, char *argv[])
{
 int i,Frames=0;
 unsigned long t1=0,t2,t3,t4;
 float Time;
 double k=18.334;
 int ForceGeneric=0;
 int Surface=1,UnoMas;

 for (i=1; i<argc; i++)
    {
     UnoMas=i<argc-1;
     if (argv[i][0]=='-')
       {
        switch (argv[i][1])
          {
           case 's':
                WaitSync=0;
                break;
           case 'g':
                ForceGeneric=1;
                break;
           case 'h':
                PrintHelp();
                return 1;
           case 'i':
                ShowInfo();
                return 2;
           case 'n':
                printf("Plasma mixsurf 1\n");
                return 3;
           case 'F':
                Surface=0;
                break;
           case 'k':
                if (UnoMas)
                   k=atof(argv[++i]);
                break;
          }
       }
    }

 AllegroInit();
 CalcuInit();

 // Virtual screen
 BMPAuxScreen=create_bitmap(w,h);
 screen_buffer=BMPAuxScreen->line[0];

 RPF_MakeBlueGreen_RedBars(temp2);

 if (!ForceGeneric)
   {
    t3=rawclock();
    PLA2_InitPlasmaTables();
    t4=rawclock();
    AllegroSetMode();

    RPF_RGBBarsWithCos(temp);
    RPF_SetAllPal(temp);
    t1=rawclock();
    while (!poll_input())
      {
       for (i=0; i<1000 && !poll_input(); i++)
          {
           PLA2_Step2(screen_buffer);
           RPF_RGBBarsWithCos(temp);
           if (WaitSync)
              vsync();
           PS_FullBlitLinear(BMPAuxScreen,screen);
           Frames++;
           RPF_SetAllPal(temp);
          }
       if (i<1000) break;
       RPF_SetAllPal(temp2);
       for (i=0; i<1000 && !poll_input(); i++)
          {
           PLA2_Step2(screen_buffer);
           if (WaitSync)
              vsync();
           PS_FullBlitLinear(BMPAuxScreen,screen);
           Frames++;
          }
       if (i<1000) break;
      }
   }
 else
   {
    t3=rawclock();
    PLA2G_InitPlasmaTables(w,h,screen_buffer,k,Surface,w*2,h*2,CalcuCallBack);
    t4=rawclock();
    AllegroSetMode();
    RPF_RGBBarsWithCos(temp);
    RPF_SetAllPal(temp);
    t1=rawclock();
    while (!poll_input())
      {
       for (i=0; i<1000 && !poll_input(); i++)
          {
//.........这里部分代码省略.........
开发者ID:TRex22,项目名称:setedit,代码行数:101,代码来源:ps2.c


示例14: main

int
main(int argc, char **argv, char **envp)
{
	struct Session session;
	time_t	t1, t2;

	int tmp = 0;

	if(RegisterHandlers() == -1)
	{
		fprintf(stderr, "[!] Cannot register signal handlers, aborting\n");
		goto cleanup;
	}
	
	InitSession(&session, envp, argv);

	if(ParseArguments(argc, argv, &session) == -1)
	{
		PrintHelp(argv[0]);
		goto cleanup;
	}

	if(OpenLogFile(&session) == -1)
	{
		fprintf(stderr, "[!] Cannot open %s for logging, aborting\n",
			session.logfilename);

		goto cleanup;
	}

	if(PrepareArgv(&session) == -1)
	{
		fprintf(stderr, "[!] Cannot parse arguments\n");
		goto cleanup;
	}
	
	if(InitFuzzingStrings(&session) == -1)
	{
		fprintf(stderr, "[!] Error initializing fuzzing variables\n");
		goto cleanup;
	}

	switch(session.mode)
	{
		/* Smart mode read the file structure from a file */ 
		case MODE_SMART:
		{
			fprintf(stdout, "[%%] Reading headers structure from %s\n",
			session.headers);

			session.headercount = Extract_DataFields(&session);
			break;
		}
		/* ASCII mode read a file and tries to get the right file structure =) */
		case MODE_ASCII:
		{
			fprintf(stdout, "[%%] Reading ASCII structure from %s\n",
				session.input);
			
			session.headercount = Extract_ASCII_Structure(&session);
			break;
		}
	}

	if((session.mode == MODE_ASCII) || (session.mode == MODE_SMART))
	{
		if(!session.headercount)
		{
			fprintf(stderr, "[!] Error loading Offsets from input file\n");
			goto cleanup;
		}

		session.range.low   = 0;
		session.range.high  = session.headercount;
		
		fprintf(stdout, "[%%] Loaded %d fields in headers\n",
			session.headercount);
	}

	tmp = CountFuzzingStrings(&session);
	
	fprintf(stdout, "[%%] Loaded %d fuzzing variables\n", tmp);
	fprintf(stdout, "[%%] Fuzzing from %d to %d\n",	session.range.low,
		session.range.high);
	
	if(session.mode == MODE_BRUTE)
	{
		session.byte = session.range.low;
		tmp         *= session.range.high - session.range.low + 1;
	}
	else
	{
		session.curfield = session.d;
		session.byte     = session.curfield->offset;
		tmp             *= session.headercount;
	}

	PrintLogHeader(&session);

	fprintf(stdout, "[%%] Number of files to be generated %d\n", tmp);
//.........这里部分代码省略.........
开发者ID:agustingianni,项目名称:ffuzzer,代码行数:101,代码来源:main.c


示例15: main

int main(int argc, char** argv)/*{{{*/
{
    bool isNonOptionArg = false;
    if(argc < 2) 
    {
        PrintHelp();
        return 0;
    }
    int i,j;
    char modmfile[MAX_PATH+1] = "";
    char modmfilelist[MAX_PATH+1] = "";
    char outfile[MAX_PATH+1] = "";
    char suppliedAlphabet[SIZE_ALPHABET+1] = ""; /*force supplied alphabet to the alphabet in the output binary file*/
    char outpath[MAX_PATH+1] = ""; /*default output path for the binary file is the same as the ascii file*/
    double value = 0.0;
    int mode = 0;
    const char control_option[] = "bp"; //options which control the program, and does not take parameters

    char tmpfile[MAX_PATH+1] = "/tmp/fileXXXXXX";
    if (mkstemp(tmpfile) == -1)
    {
        fprintf(stderr, "Error! No temporary file can be created\n");
        return -1;
    }
    FILE *fptmp = fopen(tmpfile,"w");
    bool isIDsSet = false;
    bool isOutputTimeInfo = true;

    i = 1;
    while(i < argc)/*{{{*/
    {
        if(argv[i][0] == '-' && !isNonOptionArg) //options
        {
            isNonOptionArg = false;
            if(IsInCharSet(argv[i][1], control_option))//if argv[i][1] is in control_option, it might be used as -aqs
            {
                for(j = 1 ; j < strlen(argv[i]); j++)
                {
                    switch (argv[i][j])
                    {
                        case 'b': isWriteBinaryFile = true; break;
                        case 'p': isPrintOut = true; break;
                        default : fprintf(stderr,"Invalid option, non-control option '%c' can be used together with contorl-option\n", argv[j]); return -1;
                    }
                }
                i ++;
            }
            else if(strcmp(argv[i],"-h") == 0 ||strcmp(argv[i],"--help")==0 )
            {
                PrintHelp(); 
                return 0;
            }
            else if(strcmp(argv[i],"-H") == 0 )
            {
                PrintVerboseHelp();
                return 0;
            }
            else if(strcmp(argv[i],"-a") == 0 )
            {
                my_strcpy(suppliedAlphabet, argv[i+1], SIZE_ALPHABET);
                i += 2;

            }
            else if( (strcmp(argv[i],"-o") == 0) || (strcmp(argv[i], "--out") == 0))  
            {
                if( ( i = option_parser_filename(argc, argv, i, outfile)) == -1)
                    return -1;
            }
            else if( (strcmp(argv[i], "--outpath") == 0))  
            {
                if( ( i = option_parser_filename(argc, argv, i, outpath)) == -1)
                    return -1;
            }
            else if( (strcmp(argv[i],"-l") == 0) )  
            {
                if( ( i = option_parser_filename(argc, argv, i, modmfilelist)) == -1)
                    return -1;
            }
            else if( (strcmp(argv[i], "--mode") == 0))  
            {
                if( ( i = option_parser_numeric(argc, argv, i, mode, true, 0, 1)) == -1)
                    return -1;
            }
            else if (strcmp(argv[i], "--sad") == 0)/*indicating the modm file contains SAD information*/
            {
                isHaveSAD = true;
                i ++;
            }
            else if (strcmp(argv[i], "--notime") == 0)/*do not output time info*/
            {
                isOutputTimeInfo = false;
                i ++;
            }
            else if (strcmp(argv[i], "--") == 0)//next item is non option argument
            {
                isNonOptionArg = true;
                i ++;
                continue;
            }
            else
//.........这里部分代码省略.........
开发者ID:nanjiangshu,项目名称:predzinc,代码行数:101,代码来源:test-readmodm.cpp


示例16: main


//.........这里部分代码省略.........
				break;
			case 'c':
				sscanf(optarg, "%dx%d",
					&ConfigGet(& 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PrintHex函数代码示例发布时间:2022-05-30
下一篇:
C++ PrintHeader函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap