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

C++ show_usage函数代码示例

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

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



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

示例1: main

int main(int argc, char *argv[]) {
	int c;                          /* character for getopt processing */
	/* command argument variables */
	char *first_file = NULL;
	char *second_file = NULL;
	char *a_output_file = NULL;
	char *b_output_file = NULL;
	char *c_output_file = NULL;
	FILE *a_output_fp = NULL;
	FILE *b_output_fp = NULL;
	FILE *c_output_fp = NULL;
	int use_header = 0;
	int only_summarize = 0;

	/* internal variables */
	seqdiff_results_t *results;
	results = seqdiff_results_init();

	extern char *optarg; /* external from getopt */

	verbose_flag = 0; /* assume not verbose */
	progname = argv[0]; /* capture the program name */
	if (argc < 2) {
		show_usage(EXIT_FAILURE);
	}

	while(1) {
		static struct option long_options[] =
		{
			{"verbose",    no_argument, 0, 'v'},
			{"version",    no_argument, 0, 'V'},
			{"help",       no_argument, 0, 'h'},
			{"summary",    no_argument, 0, 's'},
			{"headers",    no_argument, 0, 'd'},
			{"first",      required_argument, 0, '1'},
			{"second",     required_argument, 0, '2'},
			{"a_output",   required_argument, 0, 'a'},
			{"b_output",   required_argument, 0, 'b'},
			{"c_output",   required_argument, 0, 'c'},
			{0, 0, 0, 0}
		};

		/* getopt_long stores the option index here. */
		int option_index = 0;

		c = getopt_long(argc, argv, "vVh?sd1:2:a:b:c:", long_options, &option_index);

		/* Detect the end of the options. */
		if (c == -1)
			break;

		switch (c) {
			case 'v':
				verbose_flag = 1;
				break;

			case 'V':
				/* version */
				printf("Version is %f\n",VERSION);
				break;

			case 'h':
				show_usage(EXIT_FAILURE);
				break;

			case '?':
				/* getopt_long already printed an error message. */
				break;

			case 's':
				only_summarize = 1;
				break;

			case 'd':
				use_header = 1;
				break;

			case '1':
				first_file = (char*) malloc(strlen(optarg)+1);
				strcpy(first_file,optarg);
				break;

			case '2':
				second_file = (char*) malloc(strlen(optarg)+1);
				strcpy(second_file,optarg);
				break;

			case 'a':
				a_output_file = (char*) malloc(strlen(optarg)+1);
				strcpy(a_output_file,optarg);
				break;

			case 'b':
				b_output_file = (char*) malloc(strlen(optarg)+1);
				strcpy(b_output_file,optarg);
				break;

			case 'c':
				c_output_file = (char*) malloc(strlen(optarg)+1);
				strcpy(c_output_file,optarg);
//.........这里部分代码省略.........
开发者ID:bcthomas,项目名称:pullseq,代码行数:101,代码来源:seqdiff.c


示例2: cmdline

int cmdline(int argc, char *argv[], np_data *np)
{

	if (argc<6 || argc>7)
	{
		show_usage();
		return -1;
	}
	
	if (strlen(argv[1])>8)
	{
		printf("Start address page error!\n");
		return -1;
	}
	spage = atoi(argv[1]);
	if (spage > MAX_PAGE)
	{
		printf("Start address page error!\n");
		return -1;
	}

	if (strlen(argv[2])>8)
	{
		printf("End address page error!\n");
		return -1;
	}
	epage = atoi(argv[2]);
	if (epage > MAX_PAGE)
	{
		printf("End address page error!\n");
		return -1;
	}

	if (strlen(argv[3])>1)
	{
		printf("Operation type error!\n");
		return -1;
	}
	if (argv[3][0] == 'r') 
		ops_t = READ_FLASH;
	else if (argv[3][0] == 'w')
		ops_t = WRITE_FLASH;
	else
	{
		printf("Operation type error!\n");
		return -1;
	}

	if (strlen(argv[4])>20)
	{
		printf("Source or object file name error!\n");
		return -1;
	}
	filename = (unsigned char *)argv[4];

	if (strlen(argv[5])>2)
	{
		printf("Chip select number error!\n");
		return -1;
	}
	cs_index = atoi(argv[5]);

	if (epage <= spage)
	{
		printf("End page number must larger than start page number!\n");
		return -1;
	}

	if (argc == 7)
	{
		args_num = 7;
		if (strlen(argv[6])>3)
		{
			printf("Processor type error!\n");
			return -1;
		}
		idx = atoi(argv[6]);
		if (idx > 20)
		{
			printf("Processor type error!\n");
			return -1;
		}
	}
	else args_num = 6;

	printf("Deal command line: spage%d epage%d ops%d file:%s cs%d\n",
	       spage,epage,ops_t,filename,cs_index);

	return 0;
}
开发者ID:OpenInkpot-archive,项目名称:xburst-tools,代码行数:90,代码来源:cmdline.c


示例3: main

int main(int argc, char **argv, char **envp)
{
  struct termios tty;
  char filename[MAX_FILEPATH];
  char ch;
  int  speed;
  int  opt;
  int  oflags;
  int  ret;

  while ((opt = getopt(argc, argv, ":dt:b:hl:")) != -1)
    {
      switch(opt)
        {
        case 'd':
          debug++;
          break;

        case 't':
          g_ttydev = optarg;
          break;

        case 'b':
          g_baud = atoi(optarg);
          break;

        case 'h':
          show_usage(argv[0], 0);
          break;

        case 'l':
          g_logfile = optarg;
          break;

        case ':':
          fprintf(stderr, "ERROR: Missing argument to option '%c'\n", optopt);
          show_usage(argv[0], 1);
          break;

        case '?':
          fprintf(stderr, "ERROR: Unrecognized option '%c'\n", optopt);
          show_usage(argv[0], 2);
          break;
        }
    }

  if (optind < argc)
    {
      fprintf(stderr, "ERROR: Unexpected arguments at end of line\n");
      show_usage(argv[0], 3);
    }

  switch (g_baud)
    {
    case 0:      speed = B0;      break;
    case 50:     speed = B50;     break;
    case 75:     speed = B75;     break;
    case 110:    speed = B110;    break;
    case 134:    speed = B134;    break;
    case 150:    speed = B150;    break;
    case 200:    speed = B200;    break;
    case 300:    speed = B300;    break;
    case 600:    speed = B600;    break;
    case 1200:   speed = B1200;   break;
    case 1800:   speed = B1800;   break;
    case 2400:   speed = B2400;   break;
    case 4800:   speed = B4800;   break;
    case 9600:   speed = B9600;   break;
    case 19200:  speed = B19200;  break;
    case 38400:  speed = B38400;  break;
    case 57600:  speed = B57600;  break;
    case 115200: speed = B115200; break;
    case 230400: speed = B230400; break;

    default:
      fprintf(stderr, "ERROR: Unsupported BAUD=%d\n", g_baud);
      show_usage(argv[0], 4);
    }

  /* Was a log file specified? */

  if (g_logfile)
    {
      g_logstream = fopen(g_logfile, "w");
      if (!g_logstream)
        {
          fprintf(stderr, "ERROR: Failed to open '%s' for writing\n", g_logfile);
          return 5;
        }
    }

  /* Set the host stdin to O_NONBLOCK */

  oflags = fcntl(0, F_GETFL, 0);
  if (oflags == -1)
    {
      fprintf(stderr, "ERROR: fnctl(F_GETFL) failed: %s\n", strerror(errno));
      return 6;
    }

//.........这里部分代码省略.........
开发者ID:jrosberg,项目名称:NuttX-L21,代码行数:101,代码来源:shterm.c


示例4: main

int main(int argc, char * argv[])
{
	int result = 0;
	static struct option options[] = {
		{ "help",	0, NULL, 'h' },
		{ "info",	0, NULL, 'i' },
		{ "fork",	0, NULL, 'f' },
		{ "server",	1, NULL, 's' },
		{ "pidfile",	1, NULL, 'p' },
		{ "timeout",	1, NULL, 't' },
		{ "verbose",	1, NULL, 'v' },
		{  NULL,	0, NULL,  0  },
	};

	while ((result = getopt_long(argc, argv, "+hfis:p:t:v:", options, NULL)) != -1) {
		switch (result) {
		case 'h':
			show_usage(STATUS_SUCCESS);
			break;
		case 'i':
			show_author(STATUS_SUCCESS);
			break;
		case 'f':
			gDaemonState |= DSTATE_DOFORK;
			break;
		case 's':
			gServerAddress = optarg;
			break;
		case 'p':
			gPidFileName = optarg;
			break;
		case 't':
			gEventTimeout = atoi(optarg);
			if (gEventTimeout < 1)
				gEventTimeout = 1;
			if (gEventTimeout > 60)
				gEventTimeout = 60;
			break;
		case 'v':
			gVerboseLevel = atoi(optarg);
			if (gVerboseLevel < 0)
				gVerboseLevel = 1;	/* LOG_ERR */
			if (gVerboseLevel > 5)
				gVerboseLevel = 5;	/* LOG_DBG */
			break;
		default:
			show_usage(STATUS_FAILURE);
		}
	}


	if (optind < argc) {
		gUserPassword = argv[optind++];
		if (optind < argc)
			show_usage(STATUS_FAILURE);
	}

	/*
	 * OK, let's validate the data and do all the work
	 */

	if (validate())
		return STATUS_FAILURE;

	return do_the_work();
}
开发者ID:milabs,项目名称:hntlogd,代码行数:66,代码来源:daemon.c


示例5: main

int
main(int argc, char **argv)
{
        // Standard command line parsing.
        HASH_T *options = parse_cmdline(argc, argv, arg_opts);
        if(options == NULL || hash_get(options, "help") != NULL) {
                show_usage(argc, argv, arg_opts);
                return 1;
        }

        char *url = hash_get(options, "url");
        const char *principal = hash_get(options, "principal");
        CREDENTIALS_T *credentials = NULL;
        const char *password = hash_get(options, "credentials");
        if(password != NULL) {
                credentials = credentials_create_password(password);
        }
        char *topic = hash_get(options, "topic");

        // Setup for condition variable.
        apr_initialize();
        apr_pool_create(&pool, NULL);
        apr_thread_mutex_create(&mutex, APR_THREAD_MUTEX_UNNESTED, pool);
        apr_thread_cond_create(&cond, pool);

        // Create a session with Diffusion.
        SESSION_T *session = NULL;
        DIFFUSION_ERROR_T error;
        session = session_create(url, principal, credentials, NULL, NULL, &error);
        if(session == NULL) {
                fprintf(stderr, "TEST: Failed to create session\n");
                fprintf(stderr, "ERR : %s\n", error.message);
                return 1;
        }

        // Create a payload.
        char *data = hash_get(options, "data");
        BUF_T *payload = buf_create();
        buf_write_bytes(payload, data, strlen(data));

        // Build up some headers to send with the message.
        LIST_T *headers = list_create();
        list_append_last(headers, "apple");
        list_append_last(headers, "train");

        // Parameters for send_msg() call.
        SEND_MSG_PARAMS_T params = {
                .topic_path = topic,
                .payload = *payload,
                .headers = headers,
                .priority = CLIENT_SEND_PRIORITY_NORMAL,
                .on_send = on_send,
                .context = "FOO"
        };

        // Send the message and wait for the callback to acknowledge delivery.
        apr_thread_mutex_lock(mutex);
        send_msg(session, params);
        apr_thread_cond_wait(cond, mutex);
        apr_thread_mutex_unlock(mutex);

        // Politely close the client connection.
        session_close(session, &error);

        return 0;
}
开发者ID:lspacagna,项目名称:diffusion-examples,代码行数:66,代码来源:send-msg.c


示例6: main

int main(int argc,char **argv)
{
  FILE *fp,*gp;
  long p;
  int32_t be64;
  size_t len;
  size_t i;
  unsigned char *dta = NULL;
  genidl_read_config ("./genidl.conf");
  if (scanArgs (--argc, ++argv) < 0)
    {
       show_usage ();
    }
#ifdef REDIRECTOR
  doredirect(use_redirector);
#endif
  for (i = 0; i < file_args_cnt; i++)
    {
      char s[1024], *idl_basename,*org_basename;
      int start, end;
      gp = fopen (file_args[i], "rb");
      if (!gp)
	{
	  fprintf (stderr, "Failed to open file ,%s'.\n", file_args[i]);
	  continue;
	}
      p = genidl_ispe (gp, &be64);

      if (is_verbose)
        fprintf (stderr, "Found PE at %ld (%s bits)\n", p, !be64 ? "32" : "64");

      end = genidl_pe_typelib_resource_count (gp);

      if (is_verbose)
	fprintf (stderr, "Contains %d typelib resource(s)\n", end);
      org_basename = get_idl_basename (file_args[i]);
      idl_basename = strdup (org_basename);
      if (strrchr (idl_basename, '.') != NULL)
	*strrchr (idl_basename, '.') = 0;

      for (start = 0; start < end; start++)
	{
	  genidl_pe_typelib_resource_read (gp, start, &dta, &len);
	  if (generate_header == 0)
	  {
	    if (end != 1)
	      sprintf (s, "%s%s_%d.idl", idl_basename, basedumpname, start);
	    else
	      sprintf (s, "%s%s.idl", idl_basename, basedumpname);
	    fp = fopen (s, "wb");
	    if (fp)
	      {
		sTI2TypLib *tl = TI2_typlib_init (dta, (size_t) len);
		if (tl)
	      {
		TI2_typlib_idl (fp, tl, org_basename);
		TI2_typlib_dest (tl);
	      }
	      if (show_dump_too)
		dumpInfo (fp, dta, len);
	      fclose (fp);
	    }
	}
	else if (generate_header == 1)
	{
	    if (end != 1)
	      sprintf (s, "%s%s_%d.h", idl_basename, basedumpname, start);
	    else
	      sprintf (s, "%s%s.h", idl_basename, basedumpname);
	    fp = fopen (s, "wb");
	    if (fp)
		  {
		    sTI2TypLib *tl = TI2_typlib_init (dta, (size_t) len);
		    if (tl)
		  {
		    TI2_typlib_hdr (fp, tl, org_basename);
		    TI2_typlib_dest (tl);
		  }
		  fclose (fp);
		}
	    }
	}
	free (idl_basename);
	free (org_basename);
	fclose (gp);
      }
  /* genidl_save_config_fp (stderr); */
  genidl_save_config ("./genidl.conf");
  return 0;
}
开发者ID:Alexpux,项目名称:mingw-w64,代码行数:90,代码来源:genidl.c


示例7: main

int
main(int argc, char **argv)
{
    rstatus_i status = CC_OK;
    FILE *fp = NULL;

    if (argc > 2) {
        show_usage();
        exit(EX_USAGE);
    }

    if (argc == 1) {
        log_stderr("launching server with default values.");
    }

    if (argc == 2) {
        if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) {
            show_usage();
            exit(EX_OK);
        }
        if (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0) {
            show_version();
            exit(EX_OK);
        }
        if (strcmp(argv[1], "-c") == 0 || strcmp(argv[1], "--config") == 0) {
            option_describe_all((struct option *)&setting, nopt);
            exit(EX_OK);
        }
        if (strcmp(argv[1], "-s") == 0 || strcmp(argv[1], "--stats") == 0) {
            metric_describe_all((struct metric *)&stats, nmetric);
            exit(EX_OK);
        }
        fp = fopen(argv[1], "r");
        if (fp == NULL) {
            log_stderr("cannot open config: incorrect path or doesn't exist");
            exit(EX_DATAERR);
        }
    }

    if (option_load_default((struct option *)&setting, nopt) != CC_OK) {
        log_stderr("failed to load default option values");
        exit(EX_CONFIG);
    }

    if (fp != NULL) {
        log_stderr("load config from %s", argv[1]);
        status = option_load_file(fp, (struct option *)&setting, nopt);
        fclose(fp);
    }
    if (status != CC_OK) {
        log_stderr("failed to load config");
        exit(EX_DATAERR);
    }

    setup();
    option_print_all((struct option *)&setting, nopt);

    core_run(&worker_processor);

    exit(EX_OK);
}
开发者ID:huayl,项目名称:pelikan,代码行数:61,代码来源:main.c


示例8: e_usage

void e_usage(void)
{
    show_usage();
    e_exit(EXIT_USAGE);
}
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:5,代码来源:main.cpp


示例9: main

int main(int argc, char *argv[])
{
#ifdef HAVE_MPI
    MPI_Init(&argc, &argv);
#endif

    std::string in_type  = "exodus";
    std::string out_type = "exodus";

    Globals globals;

    codename   = argv[0];
    size_t ind = codename.find_last_of('/', codename.size());
    if (ind != std::string::npos) {
        codename = codename.substr(ind + 1, codename.size());
    }

    Ioss::Init::Initializer io;

    std::string input_file;
    globals.scale_factor = 8.0;

    // Skip past any options...
    int i = 1;
    while (i < argc && argv[i][0] == '-') {
        if (std::strcmp("-directory", argv[i]) == 0 || std::strcmp("--directory", argv[i]) == 0 ||
                std::strcmp("-d", argv[i]) == 0) {
            i++;
            globals.working_directory = argv[i++];
        }
        else if (std::strcmp("--in_type", argv[i]) == 0) {
            i++;
            in_type = argv[i++];
        }
        else if (std::strcmp("--out_type", argv[i]) == 0) {
            i++;
            out_type = argv[i++];
        }
        else if (std::strcmp("-i", argv[i]) == 0 || std::strcmp("--input", argv[i]) == 0) {
            i++;
            input_file = argv[i++];
        }
        else if (std::strcmp("--scale_factor", argv[i]) == 0) {
            i++;
            globals.scale_factor = std::strtod(argv[i++], nullptr);
        }

        // Found an option.  See if it has an argument...
        else if (i + 1 < argc && argv[i + 1][0] == '-') {
            // No argument, another option
            i++;
        }
        else {
            // Skip the argument...
            i += 2;
        }
    }

    std::string in_file;
    std::string out_file;

    // If two or more arguments are specified at end of command line, they are
    // the input and output files to be converted.
    // The file types are assumed to be as 'hardwired' above...

    std::string cwd = globals.working_directory;

    if (input_file.empty()) {
        if (argc - i == 2) {
            in_file  = Ioss::Utils::local_filename(argv[i++], in_type, cwd);
            out_file = Ioss::Utils::local_filename(argv[i++], out_type, cwd);
        }
    }

    if (in_file.empty() || out_file.empty()) {
        show_usage(codename);
        return (EXIT_FAILURE);
    }

    OUTPUT << "Input:    '" << in_file << "', Type: " << in_type << '\n';
    OUTPUT << "Output:   '" << out_file << "', Type: " << out_type << '\n';
    OUTPUT << '\n';

    create_sph(in_file, in_type, out_file, out_type, globals);

    OUTPUT << "\n" << codename << " execution successful.\n";
#ifdef HAVE_MPI
    MPI_Finalize();
#endif
    return EXIT_SUCCESS;
}
开发者ID:uppatispr,项目名称:trilinos-official,代码行数:91,代码来源:sphgen.C


示例10: main

int main(int argc, char **argv) {
  int c = 0, res = 0;
  int verbose = FALSE;
  char *cp, *progname = *argv;
  const char *cmdopts = "c:f:hv";

  cp = strrchr(progname, '/');
  if (cp != NULL)
    progname = cp+1;

  opterr = 0;
  while ((c =
#ifdef HAVE_GETOPT_LONG
	 getopt_long(argc, argv, cmdopts, opts, NULL)
#else /* HAVE_GETOPT_LONG */
	 getopt(argc, argv, cmdopts)
#endif /* HAVE_GETOPT_LONG */
	 ) != -1) {
    switch (c) {
      case 'h':
        show_usage(progname, 0);
        break;

      case 'f':
        util_set_scoreboard(optarg);
        break;

      case 'c':
        config_filename = strdup(optarg);
        break;

      case 'v':
        verbose = TRUE;
        break;

      case '?':
        fprintf(stderr, "unknown option: %c\n", (char) optopt);
        show_usage(progname, 1);
        break;
    }
  }

  /* First attempt to check the supplied/default scoreboard path.  If this is
   * incorrect, try the config file kludge.
   */
  if (check_scoreboard_file() < 0) {
    char *path;

    path = util_scan_config(config_filename, "ScoreboardFile");
    if (path) {
      util_set_scoreboard(path);
      free(path);
    }

    if (check_scoreboard_file() < 0) {
      fprintf(stderr, "%s: %s\n", util_get_scoreboard(), strerror(errno));
      fprintf(stderr, "(Perhaps you need to specify the ScoreboardFile with -f, or change\n");
      fprintf(stderr," the compile-time default directory?)\n");
      exit(1);
    }
  }

  res = util_scoreboard_scrub(verbose);
  if (res < 0) {
    fprintf(stderr, "error scrubbing scoreboard %s: %s\n",
      util_get_scoreboard(), strerror(errno));
    return 1;
  }

  return 0;
}
开发者ID:Nakor78,项目名称:proftpd,代码行数:71,代码来源:ftpscrub.c


示例11: cpp_main

int cpp_main(int argc, char* argv[])
{
   //
   // Before anything else replace Boost.filesystem's file
   // name checker with one that does nothing (we only deal
   // with files that already exist, if they're not portable
   // names it's too late for us to do anything about it).
   //
   /*boost::filesystem::path::default_name_check(filesystem_name_check);*/
   //
   // without arguments just show help:
   //
   if(argc < 2)
   {
      std::cout << "Error: insufficient arguments, don't know what to do." << std::endl;
      show_usage();
      return 1;
   }
   //
   // create the application object:
   //
   pbcp_application papp(bcp_application::create());
   //
   // work through args, and tell the application
   // object what ir needs to do:
   //
   bool list_mode = false;
   std::list<const char*> positional_args;
   for(int i = 1; i < argc; ++i)
   {
      if(0 == std::strcmp("-h", argv[i])
         || 0 == std::strcmp("--help", argv[i]))
      {
         show_usage();
         return 0;
      }
      if(0 == std::strcmp("-v", argv[i])
         || 0 == std::strcmp("--version", argv[i]))
      {
         std::cout << "bcp " << (BOOST_VERSION / 100000) << "." << (BOOST_VERSION / 100 % 1000) << "." << (BOOST_VERSION % 100) << std::endl;
         std::cout << __DATE__ << std::endl;
         return 0;
      }
      else if(0 == std::strcmp("--list", argv[i]))
      {
         list_mode = true;
         papp->enable_list_mode();
      }
      else if(0 == std::strcmp("--list-short", argv[i]))
      {
         list_mode = true;
         papp->enable_summary_list_mode();
      }
      else if(0 == std::strcmp("--report", argv[i]))
      {
         papp->enable_license_mode();
      }
      else if(0 == std::strcmp("--cvs", argv[i]))
      {
         papp->enable_cvs_mode();
      }
      else if(0 == std::strcmp("--svn", argv[i]))
      {
         papp->enable_svn_mode();
      }
      else if(0 == std::strcmp("--scan", argv[i]))
      {
         papp->enable_scan_mode();
      }
      else if(0 == std::strcmp("--bsl-convert", argv[i]))
      {
         papp->enable_bsl_convert_mode();
      }
      else if(0 == std::strcmp("--bsl-summary", argv[i]))
      {
         papp->enable_bsl_summary_mode();
      }
      else if(0 == std::strcmp("--unix-lines", argv[i]))
      {
         papp->enable_unix_lines();
      }
      else if(0 == std::strncmp("--boost=", argv[i], 8))
      {
         papp->set_boost_path(argv[i] + 8);
      }
      else if(0 == std::strncmp("--namespace=", argv[i], 12))
      {
         papp->set_namespace(argv[i] + 12);
      }
      else if(0 == std::strncmp("--namespace-alias", argv[i], 17))
      {
         papp->set_namespace_alias(true);
      }
      else if(0 == std::strncmp("--list-namespaces", argv[i], 17))
      {
         list_mode = true;
         papp->set_namespace_list(true);
      }
      else if(0 == std::strncmp("--module-list-file=", argv[i], 19))
      {
//.........这里部分代码省略.........
开发者ID:lgatto,项目名称:proteowizard,代码行数:101,代码来源:main.cpp


示例12: main

int main(int argc, char *argv[])
{
  extern int optind;
  int i = 0;
  int c;
  gp_boolean usage = false;
  gp_boolean update_archive = false;
  gp_boolean no_index = false;
  gp_archive_type *object = NULL;

  gp_init();

  /* symbols are case sensitive */
  definition_tbl = push_symbol_table(NULL, false);
  symbol_index = push_symbol_table(NULL, false);

  while ((c = GETOPT_FUNC) != EOF) {
    switch (c) {
    case '?':
    case 'h':
      usage = true;
      break;
    case 'c':
      select_mode(ar_create);
      break;
    case 'd':
      select_mode(ar_delete);
      break;
    case 'n':
      no_index = true;
      break;
    case 'q':
      gp_quiet = true;
      break;
    case 'r':
      select_mode(ar_replace);
      break;
    case 's':
      select_mode(ar_symbols);
      break;
    case 't':
      select_mode(ar_list);
      break;
    case 'v':
      fprintf(stderr, "%s\n", GPLIB_VERSION_STRING);
      exit(0);
      break;
    case 'x':
      select_mode(ar_extract);
      break;
    }
    if (usage)
      break;
  }

  if (optind < argc) {
    /* fetch the library name */
    state.filename = argv[optind++];
    /* some operations require object filenames or membernames */
    for ( ; optind < argc; optind++) {
      state.objectname[state.numobjects] = argv[optind];
      if (state.numobjects >= MAX_OBJ_NAMES) {
        gp_error("exceeded maximum number of object files");
        break;
      }
      state.numobjects++;
    }
  } else {
    usage = true;
  }

  /* User did not select an operation */
  if (state.mode == ar_null) {
    usage = true;
  }

  /* User did not provide object names */
  if ((state.mode != ar_list) && 
      (state.mode != ar_symbols) && 
      (state.numobjects == 0)) {
    usage = true;
  }

  if (usage) {
    show_usage();
  }

  /* if we are not creating a new archive, we have to read an existing one */
  if (state.mode != ar_create) {
    if (gp_identify_coff_file(state.filename) != archive_file) {
      gp_error("\"%s\" is not a valid archive file", state.filename);
      exit(1);
    } else {
      state.archive = gp_archive_read(state.filename);
    }
  }
    
  /* process the option */
  i = 0;
  switch (state.mode) {
//.........这里部分代码省略.........
开发者ID:jdelgadoalfonso,项目名称:gputils,代码行数:101,代码来源:gplib.c


示例13: main


//.........这里部分代码省略.........
                {
                    do_alarm = 1;

                    /*! skip over to alarm time */
                    if(++cur_arg >= argc) { break; }

                    /*! attempt to parse key ID */
                    sscanf(argv[cur_arg], "%u", &alarm_time);
                }
                break;

                case 's':
                    do_shutdown = 1;
                    break;

                case 'd':
                    print_all = 1;
                    break;

                case '-':
                    print_usage = 1;
                    break;

                default:
                    fprintf(stderr, "Warning: Unrecognized option \"%s\"\n", argv[cur_arg]);
                    break;
            }
        }
    }

    /*! optionally, print usage */
    if(print_usage)
    {
        show_usage();
        goto cleanup;
    }

    /*! create CPI instance */
    {
        cpi_info_t cpi_info = { 0 };

        /*!< @hack @todo enable hung CPI timeout */
        enable_timeout(10);

        int ret = cpi_create(&cpi_info, &p_cpi);

        if(CPI_FAILED(ret))
        {
            fprintf(stderr, "Error: cpi_create failed (%s)\n", CPI_RETURN_CODE_LOOKUP[ret]);
            goto cleanup;
        }
    }

    /*! initialize CPI instance */
    {
        /*!< @hack @todo enable hung CPI timeout */
        enable_timeout(10);

        int ret = cpi_init(p_cpi, serial_device_path);

        if(CPI_FAILED(ret))
        {
            fprintf(stderr, "Error: cpi_init failed (%s)\n", CPI_RETURN_CODE_LOOKUP[ret]);
            goto cleanup;
        }
    }
开发者ID:sutajiokousagi,项目名称:cpi,代码行数:67,代码来源:main.c


示例14: init_arguments

/*
 * ===  FUNCTION  ======================================================================
 *         Name:  init_arguments
 *  Description:  初始化和解释命令行的字符串。getopt_long
 * =====================================================================================
 */
void init_arguments(int *argc, char ***argv)
{
    /* Option struct for progrm run arguments */
    static struct option long_options[] =
        {
        {"help",        no_argument,        0,              'h'},
        {"background",  no_argument,        &background,    1},
        {"dhcp",        no_argument,        &dhcp_on,       1},
        {"device",      required_argument,  0,              2},
        {"ver",         required_argument,  0,              3},
        {"username",    required_argument,  0,              'u'},
        {"password",    required_argument,  0,              'p'},
        {"ip",          required_argument,  0,              4},
        {"mask",        required_argument,  0,              5},
        {"gateway",     required_argument,  0,              'g'},
        {"dns",         required_argument,  0,              'd'},
        {0, 0, 0, 0}
        };
    int c;
    while (1) {

        /* getopt_long stores the option index here. */
        int option_index = 0;
        c = getopt_long ((*argc), (*argv), "u:p:g:d:hbl",
                        long_options, &option_index);
        if (c == -1)
            break;
        switch (c) {
            case 0:
               break;
            case 'b':
                background = 1;
                break;
            case 2:
                dev = optarg;
                break;
            case 3:
                client_ver = optarg;
                break;
            case 4:
                user_ip = optarg;
                break;
            case 5:
                user_mask = optarg;
                break;
            case 'u':
                username = optarg;
                break;
            case 'p':
                password = optarg;
                break;
            case 'g':
                user_gateway = optarg;
                break;
            case 'd':
                user_dns = optarg;
                break;
            case 'l':
                exit_flag = 1;
                break;
            case 'h':
                show_usage();
                exit(EXIT_SUCCESS);
                break;
            case '?':
                if (optopt == 'u' || optopt == 'p'|| optopt == 'g'|| optopt == 'd')
                    fprintf (stderr, "Option -%c requires an argument.\n", optopt);
                exit(EXIT_FAILURE);
                break;
            default:
                fprintf (stderr,"Unknown option character `\\x%x'.\n", c);
                exit(EXIT_FAILURE);
        }
    }
}
开发者ID:ouyangshiliang,项目名称:zdclient-for-openwrt,代码行数:81,代码来源:zdclient.c


示例15: pass_args

static int
pass_args (int argc, char **argv)
{
  int has_file = 0;
  int has_error = 0;
  while (argc-- > 0)
    {
      int is_pos = 1;
      char *h = *argv++;
      if (h[0] != '-')
        {
	  has_file = 1;
	  file_name = h;
	  continue;
	}
      switch (h[1])
        {
	case 'p':
	  if (h[2] != 0)
	    goto error_point;
	  if (argc == 0)
	    {
	      fprintf (stderr, "Missing argument for -p\n");
	      show_usage ();
	    }
	  h = *argv++; argc--;
	  while (*h != 0)
	    {
	      if (*h == '-') is_pos = 0;
	      else if (*h == '+') is_pos = 1;
	      else if (*h == 'l')
		{
		  if (is_pos)
		    set_pe_hdr_chara |= 0x20;
		  else
		    mask_pe_hdr_chara &= ~0x20;
		}
	      else if (*h == 'r')
		{
		  if (is_pos)
		    set_pe_hdr_chara |= 0x400;
		  else
		    mask_pe_hdr_chara &= ~0x400;
		}
	      else if (*h == 'n')
		{
		  if (is_pos)
		    set_pe_hdr_chara |= 0x800;
		  else
		    mask_pe_hdr_chara &= ~0x800;
		}
	      else if (*h == 's')
		{
		  if (is_pos)
		    set_pe_hdr_chara |= 0x1000;
		  else
		    mask_pe_hdr_chara &= ~0x1000;
		}
	      else if (*h == 'u')
		{
		  if (is_pos)
		    set_pe_hdr_chara |= 0x4000;
		  else
		    mask_pe_hdr_chara &= ~0x4000;
		}
	      else
		{
		  fprintf (stderr, "Unknown flag-option '%c' for -p\n", *h);
		  has_error = 1;
		}
	      ++h;
	    }
	  break;
	case 'd':
	  if (h[2] != 0)
	    goto error_point;
	  if (argc == 0)
	    {
	      fprintf (stderr, "Missing argument for -d\n");
	      show_usage ();
	    }
	  h = *argv++; argc--;
	  while (*h != 0)
	    {
	      switch (*h)
	        {
		case '-': is_pos = 0; break;
		case '+': is_pos = 1; break;
		case 'd':
		  if (is_pos) set_pe_opt_hdr_dll_chara |= 0x40;
		  else mask_pe_opt_hdr_dll_chara &= ~0x40;
		  break;
		case 'f':
		  if (is_pos) set_pe_opt_hdr_dll_chara |= 0x80;
		  else mask_pe_opt_hdr_dll_chara &= ~0x80;
		  break;
		case 'n':
		  if (is_pos) set_pe_opt_hdr_dll_chara |= 0x100;
		  else mask_pe_opt_hdr_dll_chara &= ~0x100;
		  break;
//.........这里部分代码省略.........
开发者ID:mingw-w64,项目名称:mingw-w64,代码行数:101,代码来源:genpeimg.c


示例16: main

int main(int argc, char *argv[])
{
  const char *p;
  unsigned long options = 0;
  int verbose = 0;
  int c;

  setlocale(LC_ALL, "");
  bindtextdomain(PACKAGE, LOCALEDIR);
  textdomain(PACKAGE);

  if (argc < 1)
    show_usage(_("Not enough arguments"));

  p = program_invocation_short_name;
  if (!strcmp(p, "setarch")) {
    argv++;
    argc--;
    if (argc < 1)
      show_usage(_("Not enough arguments"));
    p = argv[0];
    argv[0] = argv[-1];      /* for getopt_long() to get the program name */
    if (!strcmp(p, "-h") || !strcmp(p, "--help"))
      show_help();
  #if defined(__sparc64__) || defined(__sparc__)
  } else if (!strcmp(p,"sparc64")) {
      options |= ADDR_LIMIT_32BIT;
  #endif
  }
  #if defined(__sparc64__) || defined(__sparc__)
   if (!strcmp(p, "sparc32bash")) {
       if (set_arch(p, 0L))
           err(EXIT_FAILURE, _("Failed to set personality to %s"), p);
       execl("/bin/bash", NULL);
       err(EXIT_FAILURE, "/bin/bash");
   }
  #endif

  while ((c = getopt_long(argc, argv, "+hv3BFILRSTXZ", longopts, NULL)) != -1) {
    switch (c) {
    case 'h':
      show_help();
      break;
    case 'v':
      verbose = 1;
      break;
    case 'R':
	turn_on(ADDR_NO_RANDOMIZE, options);
	break;
    case 'F':
	turn_on(FDPIC_FUNCPTRS, options);
	break;
    case 'Z':
	turn_on(MMAP_PAGE_ZERO, options);
	break;
    case 'L':
	turn_on(ADDR_COMPAT_LAYOUT, options);
	break;
    case 'X':
	turn_on(READ_IMPLIES_EXEC, options);
	break;
    case 'B':
	turn_on(ADDR_LIMIT_32BIT, options);
	break;
    case 'I':
	turn_on(SHORT_INODE, options);
	break;
    case 'S':
	turn_on(WHOLE_SECONDS, options);
	break;
    case 'T':
	turn_on(STICKY_TIMEOUTS, options);
	break;
    case '3':
	turn_on(ADDR_LIMIT_3GB, options);
	break;
    case OPT_4GB:          /* just ignore this one */
      break;
    case OPT_UNAME26:
	turn_on(UNAME26, options);
	break;
    }
  }

  argc -= optind;
  argv += optind;

  if (set_arch(p, options))
    err(EXIT_FAILURE, _("Failed to set personality to %s"), p);

  if (!argc) {
    execl("/bin/sh", "-sh", NULL);
    err(EXIT_FAILURE, "/bin/sh");
  }

  execvp(argv[0], argv);
  err(EXIT_FAILURE, "%s", argv[0]);
  return EXIT_FAILURE;
}
开发者ID:pexip,项目名称:os-util-linux,代码行数:99,代码来源:setarch.c


示例17: main

int main(int argc, char * argv[]) {
	struct utsname u;

	int c;
	int flags = 0;
	int space = 0;

	while ((c = getopt(argc, argv, "ahmnrsv")) != -1) {
		switch (c) {
			case 'a':
				flags |= FLAG_ALL;
				break;
			case 's':
				flags |= FLAG_SYSNAME;
				break;
			case 'n':
				flags |= FLAG_NODENAME;
				break;
			case 'r':
				flags |= FLAG_RELEASE;
				break;
			case 'v':
				flags |= FLAG_VERSION;
				break;
			case 'm':
				flags |= FLAG_MACHINE;
				break;
			case 'h':
			default:
				show_usage(argc, argv);
				break;
		}
	}

	uname(&u);

	if (!flags) {
		/* By default, we just print the kernel name */
		flags = FLAG_SYSNAME;
	}

	if (flags & FLAG_SYSNAME) {
		if (space++) printf(" ");
		printf("%s", u.sysname);
	}

	if (flags & FLAG_NODENAME) {
		if (space++) printf(" ");
		printf("%s", u.nodename);
	}

	if (flags & FLAG_RELEASE) {
		if (space++) printf(" ");
		printf("%s", u.release);
	}

	if (flags & FLAG_VERSION) {
		if (space++) printf(" ");
		printf("%s", u.version);
	}

	if (flags & FLAG_MACHINE) {
		if (space++) printf(" ");
		printf("%s", u.machine);
	}

	printf("\n");

	return 0;
}
开发者ID:Saruta,项目名称:ToyOS,代码行数:70,代码来源:uname.c


示例18: parse_options

static RK_S32 parse_options(int argc, char **argv, VpuApiDemoCmdContext_t* cmdCxt)
{
    char *opt;
    RK_U32 optindex, handleoptions = 1, ret =0;

    if ((argc <2) || (cmdCxt == NULL)) {
        VPU_DEMO_LOG("vpu api demo, input parameter invalid\n");
        show_usage();
        return ERROR_INVALID_PARAM;
    }

    /* parse options */
    optindex = 1;
    while (optindex < argc) {
        opt = argv[optindex++];

        if (handleoptions && opt[0] == '-' && opt[1] != '\0') {
            if (opt[1] == '-') {
                if (opt[2] != '\0') {
                    opt++;
                } else {
                     handleoptions = 0;
                    continue;
                }
            }

            opt++;

            switch (*opt) {
                case 'i':
                    if (argv[optindex]) {
                        memcpy(cmdCxt->input_file, argv[optindex], strlen(argv[optindex]));
                        cmdCxt->input_file[strlen(argv[optindex])] = '\0';
                        cmdCxt->have_input = 1;
                    } else {
                        VPU_DEMO_LOG("input file is invalid\n");
                        ret = -1;
                        goto PARSE_OPINIONS_OUT;
                    }
                    break;
                case 'o':
                    if (argv[optindex]) {
                        memcpy(cmdCxt->output_file, argv[optindex], strlen(argv[optindex]));
                        cmdCxt->output_file[strlen(argv[optindex])] = '\0';
                        cmdCxt->have_output = 1;
                        break;
                    } else {
                        VPU_DEMO_LOG("out file is invalid\n");
                        ret = -1;
                        goto PARSE_OPINIONS_OUT;
                    }
                case 'd':
                    cmdCxt->disable_debug = 1;
                    break;
                case 'w':
                    if (argv[optindex]) {
                        cmdCxt->width = atoi(argv[optindex]);
                        break;
                    } else {
                        VPU_DEMO_LOG("input width is invalid\n");
                        ret = -1;
                        goto PARSE_OPINIONS_OUT;
                    }
                case 'h':
                    if ((*(opt+1) != '\0') && !strncmp(opt, "help", 4)) {
                        show_help();
                        ret = VPU_DEMO_PARSE_HELP_OK;
                        goto PARSE_OPINIONS_OUT;
                    } else if (argv[optindex]) {
                        cmdCxt->height = atoi(argv[optindex]);
                    } else {
                        VPU_DEMO_LOG("input height is invalid\n");
                        ret = -1;
                        goto PARSE_OPINIONS_OUT;
                    }
                    break;
                case 't':
                    if (argv[optindex]) {
                        cmdCxt->codec_type = atoi(argv[optindex]);
                        break;
                    } else {
                        VPU_DEMO_LOG("input codec_type is invalid\n");
                        ret = -1;
                        goto PARSE_OPINIONS_OUT;
                    }

                default:
                    if ((*(opt+1) != '\0') && argv[optindex]) {
                        if (!strncmp(opt, "coding", 6)) {
                            VPU_DEMO_LOG("coding, argv[optindex]: %s",
                                    argv[optindex]);
                            cmdCxt->coding = atoi(argv[optindex]);
                        } else if (!strncmp(opt, "vframes", 7)) {
                            cmdCxt->record_frames = atoi(argv[optindex]);
                        } else if (!strncmp(opt, "ss", 2)) {
                            cmdCxt->record_start_ms = atoi(argv[optindex]);
                        } else {
                            ret = -1;
                            goto PARSE_OPINIONS_OUT;
                        }
//.........这里部分代码省略.........
开发者ID:uplusplus,项目名称:rk

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ show_version函数代码示例发布时间:2022-05-30
下一篇:
C++ show_tree函数代码示例发布时间: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