本文整理汇总了C++中display_usage函数的典型用法代码示例。如果您正苦于以下问题:C++ display_usage函数的具体用法?C++ display_usage怎么用?C++ display_usage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了display_usage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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];
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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];
}
示例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;
}
示例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;
}