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

C++ display_usage函数代码示例

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

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



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

示例1: main

int main(int argc, char *argv[])
{
	struct option longopts[] = {
		{ "version", no_argument, NULL,	'v' },
		{ "help", no_argument, NULL, 'h' },
		{ 0, 0, 0, 0 }
	};
	int c = 0;

	/* Parse command-line options */
	while ((c = getopt_long(argc, argv, "vh", longopts, NULL)) > -1) {
		switch (c) {
		case 'h':
			display_usage(stdout);
			return EXIT_SUCCESS;
		case 'v':
			display_version();
			return EXIT_SUCCESS;
		default:
			/* Unknown option */
			display_usage(stderr);
			return EXIT_FAILURE;
		}
	}
	/* Start the wm */
	if (leaf_init() != ERR_NONE)
		return leaf_exit(EXIT_FAILURE);
	if (leaf_run() != ERR_NONE)
		return leaf_exit(EXIT_FAILURE);

	return leaf_exit(EXIT_SUCCESS);
}
开发者ID:shaoner,项目名称:leaf,代码行数:32,代码来源:leaf.c


示例2: main

int main(int argc, char *argv[])
{
    char *exec_name = argv[0];
    int option, option_index;

    static struct option long_options[] = 
    {
        {"help",0,0,'h'},
        {"version",0,0,'v'},
        {0,0,0,0}
    };

    while ((option = getopt_long(argc, argv, "hv", long_options, 
                    &option_index)) != -1)
    {
        switch(option)
        {
            case 'h':
                display_usage(exec_name);
                exit(EXIT_SUCCESS);
            case 'v':
                display_version();
                exit(EXIT_SUCCESS);
            default:
                display_usage(exec_name);
                exit(EXIT_FAILURE);
        }
    }

    begin();
    return EXIT_SUCCESS;
}
开发者ID:mrnoda,项目名称:first-demo,代码行数:32,代码来源:main.cpp


示例3: main

int			main(int ac, char *av[])
{
	char	*flags;
	char	*command;
	char	*op_list;
	t_pile	*pile_tab[2];

	command = av[0];
	if (ac < 2)
		display_usage(command);
	flags = get_flags(&ac, &av);
	if (ac < 1)
		display_usage(command);
	pile_tab[0] = save_param_to_pile(ac, av, command);
	pile_tab[1] = NULL;
	if (has_duplicate(pile_tab[0]))
		print_error();
	if (ft_strchr(flags, 'v'))
		print_piles(pile_tab);
	op_list = solve(pile_tab, flags);
	if (op_list == NULL)
		ft_putendl("Already sorted");
	else
		ft_putendl(op_list);
	return (0);
}
开发者ID:Orycterope,项目名称:push_swap,代码行数:26,代码来源:push_swap.c


示例4: main

int main( int argc, char ** argv )
{
	int opt;
	char type;
	char * dst_ip_str;

	type = '.';
	while( ( opt = getopt(argc, argv, "s:f:") ) != -1 ){
		switch( opt ){
		case 's':
			printf( "option s: %s\n", optarg );
			type = 's';
			dst_ip_str = optarg;
			break;
		case 'f':
			printf( "option f: %s\n", optarg );
			type = 'f';
			dst_ip_str = optarg;
			break;
		default:
			display_usage( argv[0] );
			exit( -1 );
		}
	}

	if( type == '.' ){
		display_usage( argv[0] );
		exit(-1);
	}

	port_scan( type, dst_ip_str );
	return 0;
}
开发者ID:WangLin2011,项目名称:simple_port_scanner,代码行数:33,代码来源:main.c


示例5: main

int main(int argc, char **argv) {
  int opt;
  while ((opt = getopt_long(argc, argv, optString, longOpts, NULL)) != -1) {
    switch(opt) {
    case 'p':
      pinStr = optarg;
      sscanf(pinStr, "%u", &pinIndex);
      break;
    case 'r':
      sscanf(optarg,"%u",&periodValue);
      break;
    case 'd':
      sscanf(optarg,"%u",&dutyValue);
      break;
    case 'h':
    case '?':
	display_usage();
        helpDisplayed = 1;
	return EXIT_SUCCESS;
      break;
    default:
      break;
    }
  }
  if (pinIndex >= 0 && pinIndex <= 7) {
    doPWM(pinIndex,periodValue,dutyValue);
  }
  else {
    display_usage();
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}
开发者ID:rti7743,项目名称:beagleboneIO,代码行数:33,代码来源:pwm.c


示例6: main

int main(int argc, char **argv) {
  int opt;
  while ((opt = getopt_long(argc, argv, optString, longOpts, NULL)) != -1) {
    switch(opt) {
    case 'p':
      pinStr = optarg;
      pinIndex = compute_pin_index(pinStr);
      break;
    case 'v':
      valueStr = optarg;
      sscanf(valueStr, "%u", &value);
      break;
    case 'h':
    case '?':
	display_usage();
        helpDisplayed = 1;
	return EXIT_SUCCESS;
      break;
    default:
      break;
    }
  }
  if (pinIndex != -1 && value != -1) {
    doMux(pinIndex, value);
  }
  else {
    display_usage();
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}
开发者ID:MuazSalah,项目名称:beagleboneIO,代码行数:31,代码来源:pinMux.c


示例7: main

//----------------------------------------------------------------------
// main
//----------------------------------------------------------------------
int
main (int argc, char *argv[])
{
    int option_error = 0;
    const char *progname = argv[0];
    if (argc < 2)
    {
        display_usage(progname);
        exit(option_error);
    }
    else if (argv[1][0] == 'g')
    {
        initialize();
        main_gdbserver(argc, argv);
        terminate();
    }
    else if (argv[1][0] == 'p')
    {
        initialize();
        main_platform(argc, argv);
        terminate();
    }
    else {
        display_usage(progname);
        exit(option_error);
    }
}
开发者ID:johndpope,项目名称:lldb,代码行数:30,代码来源:lldb-server.cpp


示例8: parse_args

static void parse_args(int argc, char **argv)
{
     int i, opt;

     if (argc != (MIN_ARG+3))
	  display_usage();
     
     initialize_arguments();
     opt = getopt(argc, argv, optString);
     while(opt != -1) {
	  switch(opt) {
	  case 'r':
	       g_args.threshold_right = strtod(optarg, (char **)NULL);
	       break;
	  case 'l':
	       g_args.threshold_left = strtod(optarg, (char **)NULL);
	       break;
	  case '?':
	       display_usage();
	       break;
	  default:
	       /* You won't actually get here. */
	       fatal("?? getopt returned character code 0%o ??\n", opt);
	  }
	  opt = getopt(argc, argv, optString);
     }
     i = optind;
     g_args.matrix_left_filename = argv[i++];
     g_args.left_filename = argv[i++];
     g_args.matrix_right_filename = argv[i++];
     g_args.right_filename = argv[i++];
     g_args.graph_filename = argv[i];
}
开发者ID:gpalma,项目名称:semep,代码行数:33,代码来源:main.c


示例9: main

int main(int argc, char **argv)
{
	const char *options_list = "hVA:P:C:L:v";
	int option;
	const char *cert = NULL;
	const char *ca_cert = NULL;
	const char *ca_path = NULL;
	const char *crl = NULL;
	int command = 0;
	char ret_message[4096];
	size_t message_sz = sizeof(ret_message);
	int rc;

	while ((option = getopt_long(argc, argv, options_list, long_options, NULL)) != -1) {
		switch (option) {
		case 'h':
			display_usage();
			return 0;
		case 'V':
			fprintf(stdout, "ssl_tool for nussl version %s\n", PACKAGE_VERSION);
			return 0;
		case 'A':
			ca_cert = strdup(optarg);
			break;
		case 'P':
			ca_path = strdup(optarg);
			break;
		case 'C':
			cert = strdup(optarg);
			break;
		case 'L':
			crl = strdup(optarg);
			break;
		case 'v':
			command = COMMAND_VERIFY;
			break;
		}
	}

	nussl_init();

	switch (command) {
	case COMMAND_VERIFY:
		rc = nussl_local_check_certificate(cert, ca_cert, ca_path, crl,
				ret_message, message_sz);
		fprintf(stdout, "nussl_local_check_certificate: %d\n"
				"message: %s\n",
				rc, ret_message);
		break;
	default:
		fprintf(stderr, "no command provided\n");
		display_usage();
		return 0;
	}

	return 0;
}
开发者ID:regit,项目名称:nufw,代码行数:57,代码来源:nussl_tool.c


示例10: main

int	main(int ac, char **av)
{
  int	nb = 0;

  if (ac != 2)
    return (display_usage(av[0]));
  if ((nb = atoif(av[1])) == -1)
    return (display_usage(av[0]));
  display_convert(nb);
  return (EXIT_SUCCESS);
}
开发者ID:Mandrilux,项目名称:convert_dec,代码行数:11,代码来源:main.c


示例11: process_args

static int process_args (LPWSTR lpCmdLine, int skip, Args & args) {
	int i, iNumArgs;
	LPWSTR * argvW;

	argvW = CommandLineToArgvW (lpCmdLine, &iNumArgs);
	// Skip over the command name
	for (i = skip; i < iNumArgs; i++)
	{
		if (wcsstr (argvW[i], L"help")
			|| !_wcsicmp (argvW[i], L"?")
			|| (wcslen(argvW[i]) == 2 && argvW[i][1] == L'?'))
		{
			display_usage();
			GlobalFree (argvW);
			return 0;
		}

		if (!_wcsicmp (argvW[i], L"q") || !_wcsicmp (argvW[i], L"quiet")) {
			args.bQuiet = true;
			continue;
		}

		if (!args.lpConnectionName) {
			wcsMallocAndCpy (&args.lpConnectionName, argvW[i]);
			continue;
		}

		if (!args.lpIPAddr) {
			wcsMallocAndCpy (&args.lpIPAddr, argvW[i]);
			continue;
		}

		if (!args.lpSubnetMask) {
			wcsMallocAndCpy (&args.lpSubnetMask, argvW[i]);
			continue;
		}

		display_usage();
		GlobalFree (argvW);
		return 0;
	}

	if (!args.lpConnectionName)
		wcsMallocAndCpy (&args.lpConnectionName, DEFAULT_NAME);
	if (!args.lpIPAddr)
		wcsMallocAndCpy (&args.lpIPAddr, DEFAULT_IP);
	if (!args.lpSubnetMask)
		wcsMallocAndCpy (&args.lpSubnetMask, DEFAULT_MASK);

	GlobalFree (argvW);

	return 1;
}
开发者ID:maxendpoint,项目名称:openafs_cvs,代码行数:53,代码来源:loopbackutils.cpp


示例12: do_grep

int do_grep(regex_t* preg, char* filename) {
    #ifdef DEBUG
    printf("----preg %d to grep file %s\n", (int)preg, filename);
    #endif

    char *label = NULL;
    FILE *file  = NULL;
    if (strcmp(filename, "-") == 0) {
        label = "(standard input)";
        file = stdin;
    } else {
        label = filename;
        file = fopen(filename, "r");
        if (file == NULL)
            display_usage(EXIT_TROUBLE, "Open file failed.", errno);
    }
    
    char linebuf[MAXLINE];
    int regexec_code = 0;
    int line_number = 0;
    while ( fgets(linebuf, MAXLINE, file) != NULL ) {
        line_number++;
        int len = strlen(linebuf) - 1;
        if ( linebuf[len] == '\n' )
            linebuf[len] = 0; //replace newline with null
        regexec_code = regexec(preg, linebuf, 0, NULL, 0);
        if (regexec_code > REG_NOMATCH) { // >1?
            regfree(preg);
            display_usage(EXIT_TROUBLE, "Match Error.", regexec_code);
        }

        /* this condition equals to:
           (regexec_code == 0 && gargs.is_invert == 0) 
           || (regexec_code == 1 && gargs.is_invert == 1)
        */
        if ( !(regexec_code ^ gargs.is_invert) ) {
            if (gargs.show_filename && gargs.show_line_number)
                printf("%s:%d:%s\n", label, line_number, linebuf);
            else if (gargs.show_filename && !gargs.show_line_number)
                printf("%s:%s\n", label, linebuf);
            else if (!gargs.show_filename && gargs.show_line_number)
                printf("%d:%s\n", line_number, linebuf);
            else
                puts(linebuf);
        }
    }

    fclose(file);
    return regexec_code;
}
开发者ID:clippit,项目名称:mygrep,代码行数:50,代码来源:mygrep.c


示例13: parse_args

static void parse_args(int argc, char **argv)
{
     int i, opt;

     opt = 0;
     initialize_arguments();
     opt = getopt(argc, argv, optString);
     while(opt != -1) {
	  switch(opt) {
	  case 'l':
	       g_args.lca = true;
	       break;
	  case 'd':
	       g_args.description = true;
	       break;
	  case 'm':
	       if (strcmp(optarg, "tax") == 0) {
		    g_args.d = DTAX;
	       } else if (strcmp(optarg, "str") == 0) {
		    g_args.d = DSTR;
	       } else if (strcmp(optarg, "ps") == 0) {
		    g_args.d = DPS;
	       } else {
		    display_usage();
	       }
	       break;
	  case 't':
	       g_args.n_threads = strtod(optarg, (char **)NULL);
	       if (0 >= g_args.n_threads)
		    fatal("Error, The minimum number of threads allowed is 1");

	       if (MAX_THREADS < g_args.n_threads)
		    fatal("Error, The maximum number of threads allowed is %d", MAX_THREADS);
	       break;
	  case '?':
	       display_usage();
	       break;
	  default:
	       /* You won't actually get here. */
	       fatal("?? getopt returned character code 0%o ??\n", opt);
	  }
	  opt = getopt(argc, argv, optString);
     }
     if ((argc - optind) != MIN_ARG)
	  display_usage();
     i = optind;
     g_args.graph_filename = argv[i++];
     g_args.desc_filename = argv[i++];
     g_args.annt_filename = argv[i];
}
开发者ID:gpalma,项目名称:taxsim,代码行数:50,代码来源:main.c


示例14: main

int main( int argc, char *argv[]){
    
    // Creates a character array with 256 locations
    char buffer[256];
    
    //  Tells the program ther is a file
    FILE *fp;
    
    // Not sure but I think this checks to see if changes have been made to the file
    if(argc < 2)
    {
        display_usage();
        return 1;
    }
    
    // Not sure but I think this checks to see if a file exists to be opened, and prints a error if it doesn't
    if (( fp = fopen( argv[1], "r" )) == NULL ){
        fprintf( stderr, "Error opening file, %s!", argv[1]);
        return(1);
    }
    
    line = 1;
    
    // Pushes program to the next line while the buffer is not empty
    while( fgets( buffer, 257, fp ) != NULL )
        fprintf(stdout, "%4d:\t%s", line++, buffer);
    
    
    // Closes file
    fclose(fp);
    return 0;
}
开发者ID:tracymcaruso,项目名称:Learning-C,代码行数:32,代码来源:2.2.c


示例15: main

int main(int argc, char **argv)
{
	struct state state;

	memset(&state, 0, sizeof(struct state));

	if (rc_read_options(&state, argc, argv) < 0)
		return EXIT_FAILURE;

	switch (state.rc.action) {
	case ACTION_NONE:
		/* this should never happen... */
		assert(0);
		break;
	case ACTION_USAGE:
		display_usage();
		break;
	case ACTION_VERSION:
		display_version();
		break;
	case ACTION_ANALYZE:
	case ACTION_RANK:
	case ACTION_PREDICT:
		db_load(&state);
		break;
	}

	return EXIT_SUCCESS;
}
开发者ID:andybug,项目名称:spreden,代码行数:29,代码来源:spreden.c


示例16: while

static char	*get_flags(int *ac, char **av[])
{
	char	*flags;
	char	*old;
	char	*command;

	flags = NULL;
	command = **av;
	*ac -= 1;
	*av += 1;
	while ((**av)[0] == '-' && ((**av)[1] == 'c' || (**av)[1] == 'v'))
	{
		if (contains_invalid_flag(**av))
		{
			free(flags);
			display_usage(command);
		}
		old = flags;
		flags = ft_strjoin(flags, **av + 1);
		free(old);
		*av += 1;
		*ac -= 1;
	}
	return (flags);
}
开发者ID:Orycterope,项目名称:push_swap,代码行数:25,代码来源:push_swap.c


示例17: load_config

Bool load_config (const char *filename)
{
    int rc;
    XML_ITEM *config = NULL;
    XML_ITEM *root   = NULL;
    char fullname[FILE_NAME_MAX + 1];

    root = xml_create ("root", NULL);

    ASSERT (filename != NULL);
    ASSERT (strlen(filename) < FILE_NAME_MAX);
    default_extension (fullname, filename, "cfg");

    rc = xml_load_file (&root, ".", fullname, FALSE);

    if (rc != XML_NOERROR)
      {
        coprintf ("Error while loading \"%s\". Check file presence and consistence",
                   fullname);
        display_usage ();
        return FALSE;;
      }

    config = xml_first_child (root);
    ASSERT (config);

    /* default server is localhost */
    main_server =   mem_strdup (xml_get_attr (config, "smtp",    "127.0.0.1"));
    main_sender =   mem_strdup (xml_get_attr (config, "sender",  "[email protected]"));
    main_dest   =   mem_strdup (xml_get_attr (config, "dest",    "[email protected]"));

    xml_free (root);

    return TRUE;
}
开发者ID:cookrn,项目名称:openamq,代码行数:35,代码来源:tstsmtp.c


示例18: check_options

static void check_options(int argc, char *argv[])
{
    char opt;
    int index;
    static struct option options[]={
        {"help", 0, NULL, 'h'},
        {"version", 0, NULL, 'V'}
    };
    
    opterr = 0;
    while((opt = getopt_long(argc, argv, "hV", options, &index)) != -1)
    {
        switch(opt) 
        {                
            case 'V':
                display_version();
                exit(1);
                break;
                
            case 'h':
                display_usage();
                exit(1);
                break;
                
            default:
                die("Unknown option: %s\nUse --help to show valid options.\n",
                        argv[optind - 1]);
                break;
        }
    }
}
开发者ID:kayahr,项目名称:wlsuite,代码行数:31,代码来源:decodepic.c


示例19: main

int main(int argc, char* argv[])
{
    if (argc != 2) {
        display_usage();
        return EXIT_FAILURE;
    }

    const char* file_name = argv[1];
    std::string file_data = read_file_data(file_name);

    std::vector<RuleNode*> nodes;
    Parser parser(file_data);
    nodes = parser.parseSyntax();

    if (nodes.empty()) {
        std::cerr << parser.getErrorInfo() << "\n";
        return EXIT_FAILURE;
    }

    for (auto& n: nodes) {
        Placer::placeNode(n);
    }

    std::string dir_name = std::string(file_name) + "_grammar";
    mkdir(dir_name.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
    generate_svg_file(dir_name, nodes);

    generate_html_file(dir_name + "/" + "all.html", nodes);

    return EXIT_SUCCESS;
}
开发者ID:marcioAlmada,项目名称:railroad-diagram-generator,代码行数:31,代码来源:main.cpp


示例20: getoptions

void getoptions(int argc, char *argv[]) {
	int opt = 0;

	/* Initialize globalArgs before we get to work. */
	globalArgs.verbosity = 0;
	globalArgs.inputFiles = NULL;
	globalArgs.numInputFiles = 0;
	opt = getopt(argc, argv, optString);
	while (opt != -1) {
		switch (opt) {
		case 'v':
			globalArgs.verbosity++;
			break;
		case 'h': /* fall-through is intentional */
		case '?':
			display_usage();
			break;
		default:
			/* You won't actually get here. */
			break;
		}
		opt = getopt(argc, argv, optString);
	}

	globalArgs.inputFiles = argv + optind;
	globalArgs.numInputFiles = argc - optind;
}
开发者ID:quchunguang,项目名称:test,代码行数:27,代码来源:moneymatch.cpp



注:本文中的display_usage函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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