示例#1
0
void parse_param(int argc, char **argv)
{
    int ch;
    while((ch = getopt(argc, argv, "i:r:l:k:")) != -1)
    {
        switch(ch)
        {
            case 'i':
                parse_ifs(optarg);
    
                //1:1 thread:nic
                int i;
                odp_cpumask_zero(&glb_param.cpu_mask);
                for(i = 0; i < glb_param.nic.num; i++)
                {
                    odp_cpumask_set(&glb_param.cpu_mask, i);
                }
                break;
            case 'r':
                memcpy(glb_param.rule_file, optarg, strlen(optarg) + 1);
                break;
            case 'l':
                memcpy(glb_param.fib_file, optarg, strlen(optarg) + 1);
                break;
            case 'k':
                memcpy(glb_param.pat_file, optarg, strlen(optarg) + 1);
                break;
            default:
                usage();
                exit(EXIT_FAILURE);
        }
    }
}
示例#2
0
文件: main.c 项目: darksoul42/bitrig
int
ctl_start(struct parse_result *res, int argc, char *argv[])
{
	int		 ch;
	char		 path[PATH_MAX];

	if (argc < 2)
		ctl_usage(res->ctl);

	if ((res->name = strdup(argv[1])) == NULL)
		errx(1, "strdup");
	argc--;
	argv++;

	while ((ch = getopt(argc, argv, "ck:m:d:i:")) != -1) {
		switch (ch) {
		case 'c':
			tty_autoconnect = 1;
			break;
		case 'k':
			if (res->path)
				errx(1, "kernel specified multiple times");
			if (realpath(optarg, path) == NULL)
				err(1, "invalid kernel path");
			if ((res->path = strdup(path)) == NULL)
				errx(1, "strdup");
			break;
		case 'm':
			if (res->size)
				errx(1, "memory specified multiple times");
			if (parse_size(res, optarg, 0) != 0)
				errx(1, "invalid memory size: %s", optarg);
			break;
		case 'd':
			if (realpath(optarg, path) == NULL)
				err(1, "invalid disk path");
			if (parse_disk(res, path) != 0)
				errx(1, "invalid disk: %s", optarg);
			break;
		case 'i':
			if (res->nifs != -1)
				errx(1, "interfaces specified multiple times");
			if (parse_ifs(res, optarg, 0) != 0)
				errx(1, "invalid interface count: %s", optarg);
			break;
		default:
			ctl_usage(res->ctl);
			/* NOTREACHED */
		}
	}

	return (vmmaction(res));
}