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

C++ print_usage函数代码示例

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

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



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

示例1: handle_arguments

// handle command line arguments
void handle_arguments(int argc, char ** argv)
{
  for (int i = 1; i < argc; ++i)
  {
    std::string arg1(argv[i]);

    if (arg1 == "-A" || arg1 == "--algorithm")
    {
      if (i + 1 < argc && argv[i + 1][0] != '-')
      {
        algorithm = argv[i + 1];
      }
      else
      {
        print_usage(argv[0], argv[i]);
      }

      ++i;
    }
    else if (arg1 == "-a" || arg1 == "--accent")
    {
      if (i + 1 < argc && argv[i + 1][0] != '-')
      {
        accents.push_back(argv[i + 1]);
      }
      else
      {
        print_usage(argv[0], argv[i]);
      }

      ++i;
    }
    else if (arg1 == "-b" || arg1 == "--broadcast")
    {
      if (i + 1 < argc && argv[i + 1][0] != '-')
      {
        settings.hosts.push_back(argv[i + 1]);
        settings.type = madara::transport::BROADCAST;
      }
      else
      {
        print_usage(argv[0], argv[i]);
      }

      ++i;
    }
    else if (arg1 == "-c" || arg1 == "--checkpoint")
    {
      if (i + 1 < argc && argv[i + 1][0] != '-')
      {
        controller_settings.checkpoint_prefix = argv[i + 1];
      }
      else
      {
        print_usage(argv[0], argv[i]);
      }

      ++i;
    }
    else if (arg1 == "--checkpoint-on-loop")
    {
      controller_settings.checkpoint_strategy =
        gams::controllers::CHECKPOINT_EVERY_LOOP;
    }
    else if (arg1 == "--checkpoint-on-send")
    {
      controller_settings.checkpoint_strategy =
        gams::controllers::CHECKPOINT_EVERY_SEND;
    }
    else if (arg1 == "--checkpoint-diffs")
    {
      controller_settings.checkpoint_strategy |=
        gams::controllers::CHECKPOINT_SAVE_DIFFS;
    }
    else if (arg1 == "--checkpoint-single-file")
    {
      controller_settings.checkpoint_strategy |=
        gams::controllers::CHECKPOINT_SAVE_ONE_FILE;
    }
    else if (arg1 == "-d" || arg1 == "--domain")
    {
      if (i + 1 < argc && argv[i + 1][0] != '-')
      {
        settings.write_domain = argv[i + 1];
      }
      else
      {
        print_usage(argv[0], argv[i]);
      }

      ++i;
    }
    else if (arg1 == "-e" || arg1 == "--rebroadcasts")
    {
      if (i + 1 < argc && argv[i + 1][0] != '-')
      {
        int hops;
        std::stringstream buffer(argv[i + 1]);
        buffer >> hops;
//.........这里部分代码省略.........
开发者ID:jredmondson,项目名称:gams,代码行数:101,代码来源:controller.cpp


示例2: main

int main(int argc, char *argv[])
{
	errcode_t ret;
	uint64_t blkno, result_blkno;
	int c, len;
	char *filename, *lookup_path, *buf;
	char *filebuf;
	char *p;
	char lookup_name[256];
	ocfs2_filesys *fs;

	blkno = 0;

	initialize_ocfs_error_table();

	while ((c = getopt(argc, argv, "i:")) != EOF) {
		switch (c) {
			case 'i':
				blkno = read_number(optarg);
				if (blkno <= OCFS2_SUPER_BLOCK_BLKNO) {
					fprintf(stderr,
						"Invalid inode block: %s\n",
						optarg);
					print_usage();
					return 1;
				}
				break;

			default:
				print_usage();
				return 1;
				break;
		}
	}

	if (optind >= argc) {
		fprintf(stderr, "Missing filename\n");
		print_usage();
		return 1;
	}
	filename = argv[optind];
	optind++;

	if (optind >= argc) {
		fprintf(stdout, "Missing path to lookup\n");
		print_usage();
		return 1;
	}
	lookup_path = argv[optind];

	ret = ocfs2_open(filename, OCFS2_FLAG_RO, 0, 0, &fs);
	if (ret) {
		com_err(argv[0], ret,
			"while opening file \"%s\"", filename);
		goto out;
	}

	ret = ocfs2_malloc_block(fs->fs_io, &buf);
	if (ret) {
		com_err(argv[0], ret,
			"while allocating inode buffer");
		goto out_close;
	}

	if (!blkno)
		blkno = OCFS2_RAW_SB(fs->fs_super)->s_root_blkno;

	for (p = lookup_path; *p == '/'; p++);

	lookup_path = p;

	for (p = lookup_path; ; p++) {
		if (*p && *p != '/')
			continue;

		memcpy(lookup_name, lookup_path, p - lookup_path);
		lookup_name[p - lookup_path] = '\0';
		ret = ocfs2_lookup(fs, blkno, lookup_name,
				   strlen(lookup_name), NULL,
				   &result_blkno);
		if (ret) {
			com_err(argv[0], ret,
				"while looking up \"%s\" in inode %"PRIu64
			       	" on \"%s\"\n",
				lookup_name, blkno, filename);
			goto out_free;
		}

		blkno = result_blkno;

		for (; *p == '/'; p++);

		lookup_path = p;

		if (!*p)
			break;
	}

	if (ocfs2_check_directory(fs, blkno) != OCFS2_ET_NO_DIRECTORY) {
		com_err(argv[0], ret, "\"%s\" is not a file", filename);
//.........这里部分代码省略.........
开发者ID:djs55,项目名称:ocfs2-tools,代码行数:101,代码来源:fileio.c


示例3: main

int main(int argc, char *argv[]) {
    struct option longopts[] = {
        { "listen",	no_argument,		NULL,	'l' },
        { "connect",	no_argument,		NULL,	'c' },
        { "send",	no_argument,		NULL,	's' },
        { "receive",	no_argument,		NULL,	'r' },
        { "port",	required_argument,	NULL,	'p' },
        { "buffer",	required_argument,	NULL,	'b' },
        { "help",	no_argument,		NULL,	'h' },
        { "version",	no_argument,		NULL,	'V' },
        { NULL, 0, NULL, 0 }
    };
    int opt;
    enum { LISTEN=1, CONNECT } mode = 0;
    enum { SEND=1, RECEIVE } direction = 0;
    int port = 0;
    int buffer_size = 0;
    char *rhost = NULL;
    int sock;

    argv0=argv[0];

    while ((opt=getopt_long(argc, argv, "-lcsrp:b:hV", longopts, NULL)) != -1) {
        switch (opt) {
            char *tailptr;
        case 'l':
            if (mode==0) mode=LISTEN;
            else param_error(NULL);
            break;
        case 'c':
            if (mode==0) mode=CONNECT;
            else param_error(NULL);
            break;
        case 's':
            if (direction==0) direction=SEND;
            else param_error(NULL);
            break;
        case 'r':
            if (direction==0) direction=RECEIVE;
            else param_error(NULL);
            break;
        case 'p':
            if (port==0) {
                errno=0;
                port = strtol(optarg, &tailptr, 0);
                if (errno || *tailptr!=0) param_error(NULL);
            }
            else param_error(NULL);
            break;
        case 'b':
            if (buffer_size==0) {
                errno=0;
                buffer_size = strtol(optarg, &tailptr, 0);
                if (errno || *tailptr!=0) param_error(NULL);
            }
            else param_error(NULL);
            break;
        case 'h':
            print_usage();
            break;
        case 'V':
            print_version();
            break;
        case 1:
            if (rhost==NULL) rhost=optarg;
            else param_error(NULL);
            break;
        case '?':
            param_error("");
            break;
        default:
            oops();
            break;
        }
    }
    if (mode==0) param_error(NULL);
    if (direction==0) direction = mode==LISTEN ? SEND : RECEIVE;
    if (port==0) param_error(NULL);
    if (port<0 || port>65535) param_error(NULL);
    if (buffer_size==0) buffer_size = DEFAULT_BUFFER_SIZE;
    if (buffer_size<0) param_error(NULL);
    if (mode==CONNECT && rhost==NULL) param_error(NULL);

    switch (mode) {
    case LISTEN:
        sock = do_listen(port, rhost);
        break;
    case CONNECT:
        sock = do_connect(port, rhost);
        break;
    default:
        oops();
        break;
    }
    switch (direction) {
    case SEND:
        do_transfer(STDIN_FILENO, sock, buffer_size);
        break;
    case RECEIVE:
        do_transfer(sock, STDOUT_FILENO, buffer_size);
//.........这里部分代码省略.........
开发者ID:jobovy,项目名称:nemo,代码行数:101,代码来源:tcppipe.c


示例4: main

int
main(int argc, char **argv)
{
    struct sigaction new_action;
    new_action.sa_handler = SIG_IGN;
    sigemptyset(&new_action.sa_mask);
    new_action.sa_flags = 0;
    sigaction(SIGPIPE, &new_action, NULL);

    int rv = 0;
    char *host = NULL;
    char *port = NULL;
    char *docroot = NULL;
    size_t max_threads = 20;
    char *ptr;
    char *endptr;

    char *tmp_host = getenv("BLOGC_RUNSERVER_DEFAULT_HOST");
    char *default_host = bc_strdup(tmp_host != NULL ? tmp_host : "127.0.0.1");
    char *tmp_port = getenv("BLOGC_RUNSERVER_DEFAULT_PORT");
    char *default_port = bc_strdup(tmp_port != NULL ? tmp_port : "8080");

    size_t args = 0;

    for (size_t i = 1; i < argc; i++) {
        if (argv[i][0] == '-') {
            switch (argv[i][1]) {
                case 'h':
                    print_help(default_host, default_port);
                    goto cleanup;
                case 'v':
                    printf("%s\n", PACKAGE_STRING);
                    goto cleanup;
                case 't':
                    if (argv[i][2] != '\0')
                        host = bc_strdup(argv[i] + 2);
                    else
                        host = bc_strdup(argv[++i]);
                    break;
                case 'p':
                    if (argv[i][2] != '\0')
                        port = bc_strdup(argv[i] + 2);
                    else
                        port = bc_strdup(argv[++i]);
                    break;
                case 'm':
                    if (argv[i][2] != '\0')
                        ptr = argv[i] + 2;
                    else
                        ptr = argv[++i];
                    max_threads = strtoul(ptr, &endptr, 10);
                    if (*ptr != '\0' && *endptr != '\0')
                        fprintf(stderr, "blogc-runserver: warning: invalid value "
                            "for -m argument: %s. using %zu instead\n", ptr, max_threads);
                    break;
                default:
                    print_usage();
                    fprintf(stderr, "blogc-runserver: error: invalid "
                        "argument: -%c\n", argv[i][1]);
                    rv = 1;
                    goto cleanup;
            }
        }
        else {
            if (args > 0) {
                print_usage();
                fprintf(stderr, "blogc-runserver: error: only one positional "
                    "argument allowed\n");
                rv = 1;
                goto cleanup;
            }
            args++;
            docroot = bc_strdup(argv[i]);
        }
    }

    if (docroot == NULL) {
        print_usage();
        fprintf(stderr, "blogc-runserver: error: document root directory "
            "required\n");
        rv = 1;
        goto cleanup;
    }

    if (max_threads <= 0 || max_threads > 1000) {
        print_usage();
        fprintf(stderr, "blogc-runserver: error: invalid value for -m. "
            "Must be integer > 0 and <= 1000\n");
        rv = 1;
        goto cleanup;
    }

    rv = br_httpd_run(
        host != NULL ? host : default_host,
        port != NULL ? port : default_port,
        docroot, max_threads);

cleanup:
    free(default_host);
    free(default_port);
//.........这里部分代码省略.........
开发者ID:blogc,项目名称:blogc,代码行数:101,代码来源:main.c


示例5: get_options


//.........这里部分代码省略.........
       if (*p == '\\' || *p == '"')
	   grecs_txtacc_grow_char(pp_cmd_acc, '\\');
       grecs_txtacc_grow_char(pp_cmd_acc, *p);
   }
   grecs_txtacc_grow_char(pp_cmd_acc, '"');			

#line 168
	     break;
#line 168
	  }
#line 171 "cmdline.opt"
	 case 'h':
#line 171
	  {
#line 171

#line 171
		print_help ();
#line 171
		exit (0);
#line 171
	 
#line 171
	     break;
#line 171
	  }
#line 171 "cmdline.opt"
	 case OPTION_USAGE:
#line 171
	  {
#line 171

#line 171
		print_usage ();
#line 171
		exit (0);
#line 171
	 
#line 171
	     break;
#line 171
	  }
#line 171 "cmdline.opt"
	 case 'V':
#line 171
	  {
#line 171

#line 171
		/* Give version */
#line 171
		print_version(program_version, stdout);
#line 171
		exit (0);
#line 171
	 
#line 171
	     break;
#line 171
	  }

#line 176 "cmdline.opt"
	}
#line 176
    }
#line 176
开发者ID:baohaojun,项目名称:dico,代码行数:67,代码来源:cmdline.c


示例6: main

int main (int argc, char ** argv)
{
	//const clock_t begin_time = clock();
	
	if (argc<3) {
		print_usage ();
	}
	
	////////////////////////////////////////////////////////////
	// Init parameters
	//
	std::string input_file_name;
	std::string bv_file_name;
	std::string output_file_name;
	bool compress = false;
	
	////////////////////////////////////////////////////////////
	// Read command line arguments
	//
	int arg_pos = 1;
	while (arg_pos < argc){
		std::string flag = argv[arg_pos];
		if (flag[0] != '-') {
			if (input_file_name.empty()) {
				input_file_name = flag;
			} else if (bv_file_name.empty()){
				bv_file_name = flag;
			} else {
				std::cerr << "The mandatory files are already set, unknown file " << flag << " -> ignore\n";
			}
		} else if (flag.compare("-o") == 0) {
			arg_pos++;
			output_file_name = argv[arg_pos];
		} else if (flag.compare("-h") == 0) {
			print_usage ();
			return 0;
		} else if (flag.compare("-v") == 0) {
			std::cout << "\nextract_reads version " << version << "\n";
			return 0;
		} else {
			std::cerr << "Unknown option " << flag << "\n";
            print_usage ();
			return (0);
		}
		arg_pos++;
	}
	
	if (input_file_name.empty()) {
		std::cerr << "Error: An input file name is needed -> exit\n";
		print_usage ();
		return (0);
	} else if (bv_file_name.empty()) {
		std::cerr << "Error: A bv file name is needed -> exit\n";
		print_usage ();
		return (0);
	}
	
	////////////////////////////////////////////////////////////
	// Open the given file to check its type (fasta, fastq, gzip ?)
	//
	ReadFile * read_file = NULL;
	
	std::ifstream infile;
	infile.open(input_file_name.c_str());
	if (!infile.good()) {
		std::cerr << "Cannot open file file " << input_file_name << " -> ignore\n";
	}
	// Check the first char
	std::string basename = input_file_name.substr(input_file_name.rfind("/")+1);
	char c = infile.get();
	if (c == '>') {
		infile.close();
		read_file = new FastaFile(input_file_name, bv_file_name);
	} else if (c == '@') {
		infile.close();
		read_file = new FastqFile(input_file_name, bv_file_name);
	} else {
		infile.close();
		gzFile tmp_gz_file = (gzFile) gzopen(input_file_name.c_str(), "r");
		if (!tmp_gz_file) {
			std::cerr << "Cannot open file " << input_file_name << " -> ignore\n";
			exit(1);
		}
		c = gzgetc(tmp_gz_file);
		if (c == '>') {
			gzclose(tmp_gz_file);
			compress = true;
			read_file = new GzFastaFile(input_file_name, bv_file_name);
		} else if (c == '@') {
			gzclose(tmp_gz_file);
			compress = true;
			read_file = new GzFastqFile(input_file_name, bv_file_name);
		} else {
			std::cerr << "Unknown format: " << input_file_name << " -> ignore\n";
		}
	}
	
	////////////////////////////////////////////////////////////
	// Open the output file and write selected reads in it
	// Different behaviors if : - output file name is given
//.........这里部分代码省略.........
开发者ID:JoshuaDavid,项目名称:commet,代码行数:101,代码来源:extract_reads.cpp


示例7: main

int
main(int argc, char *argv[])
#endif
{
	iptc_handle_t handle = NULL;
	char buffer[10240];
	int c;
	char curtable[IPT_TABLE_MAXNAMELEN + 1];
	FILE *in;
	const char *modprobe = 0;
	int in_table = 0, testing = 0;

	program_name = "iptables-restore";
	program_version = IPTABLES_VERSION;
	line = 0;

	lib_dir = getenv("IPTABLES_LIB_DIR");
	if (!lib_dir)
		lib_dir = IPT_LIB_DIR;

#ifdef NO_SHARED_LIBS
	init_extensions();
#endif

	while ((c = getopt_long(argc, argv, "bcvthnM:", options, NULL)) != -1) {
		switch (c) {
			case 'b':
				binary = 1;
				break;
			case 'c':
				counters = 1;
				break;
			case 'v':
				verbose = 1;
				break;
			case 't':
				testing = 1;
				break;
			case 'h':
				print_usage("iptables-restore",
					    IPTABLES_VERSION);
				break;
			case 'n':
				noflush = 1;
				break;
			case 'M':
				modprobe = optarg;
				break;
		}
	}
	
	if (optind == argc - 1) {
		in = fopen(argv[optind], "r");
		if (!in) {
			fprintf(stderr, "Can't open %s: %s\n", argv[optind],
				strerror(errno));
			exit(1);
		}
	}
	else if (optind < argc) {
		fprintf(stderr, "Unknown arguments found on commandline\n");
		exit(1);
	}
	else in = stdin;
	
	/* Grab standard input. */
	while (fgets(buffer, sizeof(buffer), in)) {
		int ret = 0;

		line++;
		if (buffer[0] == '\n')
			continue;
		else if (buffer[0] == '#') {
			if (verbose)
				fputs(buffer, stdout);
			continue;
		} else if ((strcmp(buffer, "COMMIT\n") == 0) && (in_table)) {
			if (!testing) {
				DEBUGP("Calling commit\n");
				ret = iptc_commit(&handle);
			} else {
				DEBUGP("Not calling commit, testing\n");
				ret = 1;
			}
			in_table = 0;
		} else if ((buffer[0] == '*') && (!in_table)) {
			/* New table */
			char *table;

			table = strtok(buffer+1, " \t\n");
			DEBUGP("line %u, table '%s'\n", line, table);
			if (!table) {
				exit_error(PARAMETER_PROBLEM, 
					"%s: line %u table name invalid\n",
					program_name, line);
				exit(1);
			}
			strncpy(curtable, table, IPT_TABLE_MAXNAMELEN);
			curtable[IPT_TABLE_MAXNAMELEN] = '\0';

//.........这里部分代码省略.........
开发者ID:WiseMan787,项目名称:ralink_sdk,代码行数:101,代码来源:iptables-restore.c


示例8: print_help

/* --------------------------------------------- */
static void print_help(void) {
    print_usage() ;
    printf("WARNING: this program is not yet tested!\n");
    exit(1) ;
}
开发者ID:guo2004131,项目名称:freesurfer,代码行数:6,代码来源:mri_stats2seg.c


示例9: main

int main(int argc, char *const *argv){
	char buf[PATH_MAX+1];
	char *simcount = 0;
	int simul_count = 10;
	char *original_path = 0;
	int path_passed = 0;

	int opt= 0;
	//Specifying the expected options
	// TODO: set simcount as an optional parameter
	static struct option long_options[] = {
		{"simcount",  required_argument, 0,  's' },
		{"path",      required_argument, 0,  'p' },
		{"help",      no_argument,       0,  'h' },
		{0,           0,                 0,   0  }
	};

	int long_index =0;
	while ((opt = getopt_long(argc, argv, "s:p:",
				long_options, &long_index )) != -1) {
		switch (opt) {
			// `optarg` is a global variable from getopt.h
			case 's' : simcount = strdup(optarg);
				break;
			case 'p' : path_passed = 1; original_path = realpath(optarg, buf);
				break;
			case 'h' : print_usage(); exit(0);
			default: print_usage();
				exit(EXIT_FAILURE);
		}
	}

	// Check that a path was specified and that it is a valid path
	if (path_passed && !original_path) {
		printf("Path was given, but was invalid.\n");
		print_usage();
		exit(EXIT_FAILURE);
	} else if (!path_passed) {
		printf("Path was not specified.\n");
		print_usage();
		exit(EXIT_FAILURE);
	}

	// Convert the given "simcount" to a number, store in `simul_count`
	if (simcount){
		errno = 0;
		long tmp = strtol(simcount, 0, 10);
		// TODO: implement converter
		if (errno != 0){
			printf("Could not convert specified simcount into a valid number.\n");
			print_usage();
			exit(EXIT_FAILURE);
		}
		simul_count = tmp;
	}

	printf("original_path: %s, simul_count: %d\n", original_path, simul_count);

	reverse_file(original_path, simul_count);

	//char* test[] = {
	//	"spinelessness prayed doppelgangers notabilities syllabification unflinching",
	//	"coccyx Msgr environments subjecting Duroc ibis  fetus whack wile",
	//	"nippy demoed pretax voltmeters bougainvillea garish weedkillers",
	//};
	//int i = 0;
	//for (i = 0; i < 3; ++i){
	//	char* rv = in_place_reverse_words(strdup(test[i]));
	//	free(rv);
	//}
	return 0;
}
开发者ID:lelandbatey,项目名称:word_reverser,代码行数:72,代码来源:main.c


示例10: do_config

void do_config(int argc, char **argv)
{
	char *s;
	int i, c, known;
	int got_conffile = 0, print_config = 0;
	size_t s_len;

	for (i = 1; i < argc; i++) {
		if (argv[i][0] && (argv[i][0] != '-' || argv[i][1] == '\0')) {
			read_config_file(argv[i], config, 0);
			got_conffile = 1;
			continue;
		}

		known = 0;

		for (c = 0; config_names[c].name != NULL && !known; c++) {
			if (config_names[c].option == NULL
				|| strncmp(argv[i], config_names[c].option,
					strlen(config_names[c].option)) != 0)
				continue;

			s = NULL;

			known = 1;
			if (argv[i][strlen(config_names[c].option)] == '=')
				s = argv[i] + strlen(config_names[c].option) + 1;
			else if (argv[i][strlen(config_names[c].option)] == 0) {
				if (config_names[c].needsArgument) {
					if (i + 1 < argc)
						s = argv[++i];
					else
						known = 0;
				} else
					s = argv[i]; /* no arg, fill in something */
			} else
				known = 0;
			if (known)
				config[config_names[c].nm] = s;
		}

		if (!known && strcmp(argv[i], "--version") == 0) {
			print_version();
			exit(0);
		}
		if (!known && strcmp(argv[i], "--print-config") == 0) {
			print_config = 1;
			known = 1;
		}
		if (!known && strcmp(argv[i], "--help") == 0) {
			print_usage(argv[0], 0);
			exit(0);
		}
		if (!known && strcmp(argv[i], "--long-help") == 0) {
			print_usage(argv[0], 1);
			exit(0);
		}
		if (!known) {
			printf("%s: unknown option %s\n\n", argv[0], argv[i]);

			print_usage(argv[0], 1);
			exit(1);
		}
	}
	
	if (!got_conffile) {
		read_config_file("/etc/vpnc/default.conf", config, 1);
		read_config_file("/etc/vpnc.conf", config, 1);
	}
	
	if (!print_config) {
		for (i = 0; config_names[i].name != NULL; i++)
			if (!config[config_names[i].nm]
				&& config_names[i].get_def != NULL)
				config[config_names[i].nm] = config_names[i].get_def();
		
		opt_debug = (config[CONFIG_DEBUG]) ? atoi(config[CONFIG_DEBUG]) : 0;
		opt_nd = (config[CONFIG_ND]) ? 1 : 0;
		opt_1des = (config[CONFIG_ENABLE_1DES]) ? 1 : 0;

		if (!strcmp(config[CONFIG_AUTH_MODE], "psk")) {
			opt_auth_mode = AUTH_MODE_PSK;
		} else if (!strcmp(config[CONFIG_AUTH_MODE], "cert")) {
			opt_auth_mode = AUTH_MODE_CERT;
		} else if (!strcmp(config[CONFIG_AUTH_MODE], "hybrid")) {
			opt_auth_mode = AUTH_MODE_HYBRID;
		} else {
			printf("%s: unknown authentication mode %s\nknown modes: psk cert hybrid\n", argv[0], config[CONFIG_AUTH_MODE]);
			exit(1);
		}
#ifndef OPENSSL_GPL_VIOLATION
		if (opt_auth_mode == AUTH_MODE_HYBRID ||
			opt_auth_mode == AUTH_MODE_CERT) {
			printf("%s was built without openssl: Can't do hybrid or cert mode.\n", argv[0]);
			exit(1);
		}
#endif
		opt_no_encryption = (config[CONFIG_ENABLE_NO_ENCRYPTION]) ? 1 : 0;
		opt_udpencapport=atoi(config[CONFIG_UDP_ENCAP_PORT]);
		
//.........这里部分代码省略.........
开发者ID:dellelce,项目名称:vpnc,代码行数:101,代码来源:config.c


示例11: usage_exit

/* ------------------------------------------------------ */
static void usage_exit(void) {
    print_usage() ;
    exit(1) ;
}
开发者ID:guo2004131,项目名称:freesurfer,代码行数:5,代码来源:mri_stats2seg.c


示例12: main

int main (int    argc, char **argv)
{
    const char *file_name;
    const char *set_value;
    const char *attr_name;
    int         watch_mode;

    struct sigaction sigact;

    sigemptyset(&sigact.sa_mask);
    sigact.sa_flags     = SA_SIGINFO;
    sigact.sa_restorer  = NULL;
    sigact.sa_sigaction = sig_handler;

    sigaction(SIGUSR1, &sigact, 0);
    sigaction(SIGINT, &sigact, 0);
    sigaction(SIGTERM, &sigact, 0);

    /* Parse command line arguments. */
    file_name  = "./person.dat";
    set_value  = NULL;
    watch_mode = 0;

    while (1)
    {
        int opt;

        opt = getopt (argc, argv, "ws:f:");
        if (opt < 0)
            break;

        switch (opt)
        {
            case 'w':
                watch_mode = 1;
                break;
            case 's':
                set_value = optarg;
                break;
            case 'f':
                file_name = optarg;
                break;
            default:
                print_usage (argv[0]);
                return -1;
        }
    }
    if (!watch_mode && optind >= argc)
    {
        print_usage (argv[0]);
        return -1;
    }
    attr_name = argv[optind];

    /* ###################################################### */

    setup(file_name);

    if(watch_mode) // watch mode 
    {
        int i = 0;

        printf("waiting...\n");
        printf("my pid is %x\n", getpid());

        // add self on watchers list
        for(i = 0; i < NOTIFY_MAX * sizeof(pid_t); i += sizeof(pid_t))
        {
            pid_t* p_pid = (pid_t *)((char *)p_mmap + i);

            if( *p_pid == 0 )
            {
                *p_pid = getpid();
                break;
            }
        }

        if(i/sizeof(pid_t) == NOTIFY_MAX)
        {
            *((pid_t *)p_mmap) = getpid();
        }

        while(1){
            sleep(2);
        }
    }

    else // not watch_mode
    {
        int         off;
        char *      data;

        if( 0 > (off = person_get_offset_of_attr(attr_name)) )
        {
            fprintf(stderr, "invalid attr name \'%s\'\n", attr_name);
            return -1;
        }

        if(set_value != NULL) // set mode
        {
//.........这里部分代码省略.........
开发者ID:enghqii,项目名称:OS-5-mmap,代码行数:101,代码来源:person.c


示例13: main

int
main(int argc, char *argv[])
#endif
{
	DYNMEM_KNP_DEFN	*p_dynmem_knp;
	kstat_ctl_t	*kctl;
	KSTAT_INFO_DEF	info_ksp;
	int		val;
	char		**pargs, **cur_pargs;

	/*
	 * grab and parse argument list
	 */
	p_dynmem_knp = dynmem_knp;
	pargs = argv;
	while (*pargs) {
		(void) printf("pargs=%x - %s\n", (uint_t)pargs, *pargs);

		cur_pargs = pargs;
		pargs++;

		if (strcmp(*cur_pargs, "h") == 0) {
			print_usage();
			return (0);
		}

		if (strcmp(*cur_pargs, "wake") == 0) {
			if ((p_dynmem_knp+DIRECTIVE)->newval == NO_VALUE)
				(p_dynmem_knp+DIRECTIVE)->newval = 0;
			(p_dynmem_knp+DIRECTIVE)->newval |= 0x01;
			continue;
		}

		if (strcmp(*cur_pargs, "hys") == 0) {
			if ((p_dynmem_knp+DIRECTIVE)->newval == NO_VALUE)
				(p_dynmem_knp+DIRECTIVE)->newval = 0;
			(p_dynmem_knp+DIRECTIVE)->newval |= 0x02;
			continue;
		}

		if (strcmp (*cur_pargs, "mon") == 0) {
			val = atoi(*pargs);
			(void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
			    val);
			pargs++;
			(p_dynmem_knp+MONITOR)->newval = val;
		}

		if (strcmp (*cur_pargs, "age1") == 0) {
			val = atoi(*pargs);
			(void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
			    val);
			pargs++;
			(p_dynmem_knp+AGECT1)->newval = val;
		}

		if (strcmp(*cur_pargs, "age2") == 0) {
			val = atoi(*pargs);
			(void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
			    val);
			pargs++;
			(p_dynmem_knp+AGECT2)->newval = val;
		}

		if (strcmp(*cur_pargs, "age3") == 0) {
			val = atoi(*pargs);
			(void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
			    val);
			pargs++;
			(p_dynmem_knp+AGECT3)->newval = val;
		}

		if (strcmp (*cur_pargs, "sec1") == 0) {
			val = atoi(*pargs);
			(void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
			    val);
			pargs++;
			if (val == 0)
				break;
			else {
				(p_dynmem_knp+SEC1)->newval = val;
				continue;
			}
		}

		if (strcmp(*cur_pargs, "sec2") == 0) {
			val = atoi(*pargs);
			pargs++;
			(void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
			    val);
			if (val == 0)
				break;
			else {
				(p_dynmem_knp+SEC2)->newval = val;
				continue;
			}
		}

		if (strcmp(*cur_pargs, "sec3") == 0) {
			val = atoi(*pargs);
//.........这里部分代码省略.........
开发者ID:CoryXie,项目名称:opensolaris,代码行数:101,代码来源:sdbc_dynmem.c


示例14: parse_opts

static void parse_opts(int argc, char *argv[])
{
	while (1) {
		static const struct option lopts[] = {
			{ "device",  1, 0, 'D' },
			{ "speed",   1, 0, 's' },
			{ "delay",   1, 0, 'd' },
			{ "bpw",     1, 0, 'b' },
			{ "loop",    0, 0, 'l' },
			{ "cpha",    0, 0, 'H' },
			{ "cpol",    0, 0, 'O' },
			{ "lsb",     0, 0, 'L' },
			{ "cs-high", 0, 0, 'C' },
			{ "3wire",   0, 0, '3' },
			{ "no-cs",   0, 0, 'N' },
			{ "ready",   0, 0, 'R' },
			{ NULL, 0, 0, 0 },
		};
		int c;

		c = getopt_long(argc, argv, "D:s:d:b:lHOLC3NR", lopts, NULL);

		if (c == -1)
			break;

		switch (c) {
		case 'D':
			device = optarg;
			break;
		case 's':
			speed = atoi(optarg);
			break;
		case 'd':
			delay = atoi(optarg);
			break;
		case 'b':
			bits = atoi(optarg);
			break;
		case 'l':
			mode |= SPI_LOOP;
			break;
		case 'H':
			mode |= SPI_CPHA;
			break;
		case 'O':
			mode |= SPI_CPOL;
			break;
		case 'L':
			mode |= SPI_LSB_FIRST;
			break;
		case 'C':
			mode |= SPI_CS_HIGH;
			break;
		case '3':
			mode |= SPI_3WIRE;
			break;
		case 'N':
			mode |= SPI_NO_CS;
			break;
		case 'R':
			mode |= SPI_READY;
			break;
		default:
			print_usage(argv[0]);
			break;
		}
	}
}
开发者ID:ckuehnel,项目名称:BeagleBone,代码行数:68,代码来源:spidev_test.c


示例15: bam_mpileup


//.........这里部分代码省略.........
        case 'f':
            mplp.fai = fai_load(optarg);
            if (mplp.fai == NULL) return 1;
            mplp.fai_fname = optarg;
            break;
        case 'd': mplp.max_depth = atoi(optarg); break;
        case 'r': mplp.reg = strdup(optarg); break;
        case 'l':
                  // In the original version the whole BAM was streamed which is inefficient
                  //  with few BED intervals and big BAMs. Todo: devise a heuristic to determine
                  //  best strategy, that is streaming or jumping.
                  mplp.bed = bed_read(optarg);
                  if (!mplp.bed) { print_error_errno("mpileup", "Could not read file \"%s\"", optarg); return 1; }
                  break;
        case 'P': mplp.pl_list = strdup(optarg); break;
        case 'p': mplp.flag |= MPLP_PER_SAMPLE; break;
        case 'g': mplp.flag |= MPLP_BCF; break;
        case 'v': mplp.flag |= MPLP_BCF | MPLP_VCF; break;
        case 'u': mplp.flag |= MPLP_NO_COMP | MPLP_BCF; break;
        case 'B': mplp.flag &= ~MPLP_REALN; break;
        case 'D': mplp.fmt_flag |= B2B_FMT_DP; fprintf(stderr, "[warning] samtools mpileup option `-D` is functional, but deprecated. Please switch to `-t DP` in future.\n"); break;
        case 'S': mplp.fmt_flag |= B2B_FMT_SP; fprintf(stderr, "[warning] samtools mpileup option `-S` is functional, but deprecated. Please switch to `-t SP` in future.\n"); break;
        case 'V': mplp.fmt_flag |= B2B_FMT_DV; fprintf(stderr, "[warning] samtools mpileup option `-V` is functional, but deprecated. Please switch to `-t DV` in future.\n"); break;
        case 'I': mplp.flag |= MPLP_NO_INDEL; break;
        case 'E': mplp.flag |= MPLP_REDO_BAQ; break;
        case '6': mplp.flag |= MPLP_ILLUMINA13; break;
        case 'R': mplp.flag |= MPLP_IGNORE_RG; break;
        case 's': mplp.flag |= MPLP_PRINT_MAPQ; break;
        case 'O': mplp.flag |= MPLP_PRINT_POS; break;
        case 'C': mplp.capQ_thres = atoi(optarg); break;
        case 'q': mplp.min_mq = atoi(optarg); break;
        case 'Q': mplp.min_baseQ = atoi(optarg); break;
        case 'b': file_list = optarg; break;
        case 'o': {
                char *end;
                long value = strtol(optarg, &end, 10);
                // Distinguish between -o INT and -o FILE (a bit of a hack!)
                if (*end == '\0') mplp.openQ = value;
                else mplp.output_fname = optarg;
            }
            break;
        case 'e': mplp.extQ = atoi(optarg); break;
        case 'h': mplp.tandemQ = atoi(optarg); break;
        case 'A': use_orphan = 1; break;
        case 'F': mplp.min_frac = atof(optarg); break;
        case 'm': mplp.min_support = atoi(optarg); break;
        case 'L': mplp.max_indel_depth = atoi(optarg); break;
        case 'G': {
                FILE *fp_rg;
                char buf[1024];
                mplp.rghash = khash_str2int_init();
                if ((fp_rg = fopen(optarg, "r")) == NULL)
                    fprintf(stderr, "(%s) Fail to open file %s. Continue anyway.\n", __func__, optarg);
                while (!feof(fp_rg) && fscanf(fp_rg, "%s", buf) > 0) // this is not a good style, but forgive me...
                    khash_str2int_inc(mplp.rghash, strdup(buf));
                fclose(fp_rg);
            }
            break;
        case 't': mplp.fmt_flag |= parse_format_flag(optarg); break;
        case 'a': mplp.all++; break;
        default:
            if (parse_sam_global_opt(c, optarg, lopts, &mplp.ga) == 0) break;
            /* else fall-through */
        case '?':
            print_usage(stderr, &mplp);
            return 1;
        }
    }
    if (!mplp.fai && mplp.ga.reference) {
        mplp.fai_fname = mplp.ga.reference;
        mplp.fai = fai_load(mplp.fai_fname);
        if (mplp.fai == NULL) return 1;
    }

    if ( !(mplp.flag&MPLP_REALN) && mplp.flag&MPLP_REDO_BAQ )
    {
        fprintf(stderr,"Error: The -B option cannot be combined with -E\n");
        return 1;
    }
    if (use_orphan) mplp.flag &= ~MPLP_NO_ORPHAN;
    if (argc == 1)
    {
        print_usage(stderr, &mplp);
        return 1;
    }
    int ret;
    if (file_list) {
        if ( read_file_list(file_list,&nfiles,&fn) ) return 1;
        ret = mpileup(&mplp,nfiles,fn);
        for (c=0; c<nfiles; c++) free(fn[c]);
        free(fn);
    }
    else
        ret = mpileup(&mplp, argc - optind, argv + optind);
    if (mplp.rghash) khash_str2int_destroy_free(mplp.rghash);
    free(mplp.reg); free(mplp.pl_list);
    if (mplp.fai) fai_destroy(mplp.fai);
    if (mplp.bed) bed_destroy(mplp.bed);
    return ret;
}
开发者ID:pd3,项目名称:samtools,代码行数:101,代码来源:bam_plcmd.c


示例16: main

int main(int argc, char** argv)
{
		int opt,adc;
		char buffer[MAX_BUFFER]={0};
		int fd;
		int res,c,counter,i,in;
		FILE *fp;
		float v_in,v_out;
		char *param_port = NULL;
		char *param_speed = NULL;
		char *param_imagefile=NULL;
		char *param_mode=NULL;
		char *param_backlight=NULL;
		BITMAPFILEHEADER header;
		BITMAPINFO *headerinfo;
		int headersize,bitmapsize;
		uint8_t *i_bits=NULL,*o_bits=NULL;  // input bits array from original bitmap file, output bit as converted
		int chunksize=300 * 3 ;  //default chunk of bytes to send must be set to max the device can handle without loss of data
		uint8_t b[3] ={0};
		BOOL breakout=FALSE;
		BOOL verbose_mode=FALSE;
		BOOL   has_more_data=TRUE;
		BOOL param_init=FALSE;
		BOOL  show_image=FALSE;
		BOOL show_version=FALSE;
		BOOL test_pattern_full=FALSE;
        BOOL  ADC_read=FALSE;
		printf("-----------------------------------------------------------------------------\n");
		printf("\n");
		printf(" BMP image sender for Nokia LCD Backpack V.0.3 \n");
		printf(" Wiki Docs: http://dangerousprototypes.com/docs/Mathieu:_Another_LCD_backpack\n");
		printf(" http://www.dangerousprototypes.com\n");
		printf("\n");
		printf("-----------------------------------------------------------------------------\n");

		if (argc <= 1)  {
			print_usage(argv[0]);
			exit(-1);
		}

		while ((opt = getopt(argc, argv, "iTtvVas:p:f:d:B:")) != -1) {

			switch (opt) {
				case 'p':  // device   eg. com1 com12 etc
					if ( param_port != NULL){
						printf(" Device/PORT error!\n");
						exit(-1);
					}
					param_port = strdup(optarg);
					break;
				case 'f':
					if (param_imagefile != NULL) {
						printf(" Invalid Parameter after Option -f \n");
						exit(-1);
					}
					param_imagefile = strdup(optarg);
					break;
				case 's':
					if (param_speed != NULL) {
						printf(" Speed should be set: eg  921600 \n");
						exit(-1);
					}
					param_speed = strdup(optarg);
					break;
				case 'B':    // added new: chuck size should be multiply by 3
				    // 1 * 3 up to max of file size or max port speed?
				    if ((atol(optarg) < MAX_BUFFER/3 )&&(atol(optarg)!=0) )
				         chunksize=atol(optarg)*3;
				    else {
				       printf(" Invalid chunk size parameter: using default: %i x 3 = %i Bytes\n",chunksize/3,chunksize);

				    }
				    break;
				case 'd':  // dim the backlight
					if ( param_backlight != NULL){
						printf(" Error: Parameter required to dim the backlight, Range: 0-100\n");
						exit(-1);
					}
					param_backlight = strdup(optarg);
					break;
                case 'i':    //  initialize
				    if (optarg!=NULL) {
				        printf("Invalid option in -i\n");
				    } else {
				        param_init=TRUE;
				    }
					break;
                case 'V':    //talk show some display
				    if (optarg !=NULL) {
				        printf("Invalid option in -V\n");
				    }
				    else {
				        verbose_mode=TRUE;
				    }
					break;
                case 'v':    //
				    if (optarg !=NULL) {
				        printf("Invalid option in -v\n");
				    }
				    else {
//.........这里部分代码省略.........
开发者ID:BrzTit,项目名称:dangerous-prototypes-open-hardware,代码行数:101,代码来源:main.c


示例17: main

int main(int argc, char *argv[])
{
	LINX *linx;
	LINX_SPID server_spid;
	union LINX_SIGNAL *sig;
	pthread_t server_th;
	int c;
	int loop_cnt = LOOP_CNT;
	int use_linx_api = LINX_SOCKET;
	size_t msg_size = BURST_SIZE;
	unsigned long burst_cnt = BURST_CNT;
	size_t start_msg_size = START_MSG_SIZE;
	size_t end_msg_size = END_MSG_SIZE;
	unsigned long throughput_instances = THROUGHPUT_INSTANCES;
	int iterations = ITERATIONS;
	LINX_SIGSELECT any_sig[] = { 0 };

	char *path = NULL;
	char *server_name = NULL;
	int run_attach_test = 0;
	int run_com_test = 0;
	int kill_server = 0;
	int all = 0;
	int use_pthreads = 0;

	if (argc < 2) {
		print_usage(argv[0]);
		return 0;
	}

	while ((c = getopt(argc, argv, "S?p:ac:n:m:b:i:s:e:Alt:qP")) != -1) {
		switch (c) {
		case 'S':
			/* Start server */
			server_name = (optarg == NULL ? SERVER_NAME : optarg);
			break;

		case 'P':
			/* Start server as posix thread */
			server_name = SERVER_NAME;
			use_pthreads = 1;
			break;

		case 'p':
			/* Hunt path */
			path = optarg;
			break;

		case 'a':
			/* Run attach test */
			run_attach_test = 1;
			break;

		case 'c':
			/* Connection test */
			run_com_test = atoi(optarg);
			break;

		case 'n':
			/* Loop count */
			loop_cnt = atoi(optarg);
			break;

		case 'm':
			/* Message size */
			msg_size = atol(optarg);
			break;

		case 'b':
			/* Burst count */
			burst_cnt = atol(optarg);
			break;

		case 'i':
			/* Iterations */
			iterations = atoi(optarg);
			break;

		case 's':
			/* Start message size */
			start_msg_size = atol(optarg);
			break;

		case 'e':
			/* End message size */
			end_msg_size = atol(optarg);
			break;

		case 'A':
			/* Run all tests */
			all = 1;
			break;

		case 'l':
			/* Use linx api in tests */
			use_linx_api = LINX_API;
			break;

		case 't':
			/* Number of instances in throughput */
//.........这里部分代码省略.........
开发者ID:CheukLeung,项目名称:LicenseHeaderChecker,代码行数:101,代码来源:linx_bmark.c


示例18: main

int main (int argc, char **argv)
{

  args_t args;
  LTE_DL_FRAME_PARMS frame_parms0;
  LTE_DL_FRAME_PARMS *frame_parms=&frame_parms;
  char sdu0[16],sdu1[64],sdu2[1024],sdu3[1024],sdu4[1024];
  unsigned short sdu_len0,sdu_len1,sdu_len2,sdu_len3,sdu_len4;
  char ulsch_buffer[1024],dlsch_buffer[1024];
  u8 lcid;
  u8 payload_offset;
  int i,comp;

  logInit();

  NB_UE_INST  = 1;
  NB_eNB_INST = 1;
  NB_INST=2;

  // Parse arguments
  if(parse_args(argc, argv, &args) > 0) {
    print_usage(argv[0]);
    exit(1);
  }

 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

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