Example #1
0
int					ft_flags(char **str, struct s_flags *flags, int *x)
{
	if (str[*x][1] == 'v')
	{
		flags->v = 1;
		(*x)++;
		if (str[*x] && ft_isdigit(str[*x]))
			flags->verbose = ft_verbose(ft_atoi(str[*x]));
		else
			ft_usage();
	}
	else if (str[*x][1] == 'n')
	{
		flags->n = 1;
		(*x)++;
		if (str[*x] && ft_isdigit(str[*x]))
			flags->nnbr = -1 * ft_atoi(str[*x]);
		else
			ft_usage();
	}
	else
	{
		if (!ft_flags3(str, flags, x))
			return (1);
	}
	return (0);
}
Example #2
0
void				ft_init_flags(char **str, struct s_flags *flags, int *x)
{
	if (str[*x][2] != '\0')
		ft_usage();
	if (ft_flags2(str, flags, x) && ft_flags(str, flags, x))
	{
		ft_usage();
		exit(EXIT_FAILURE);
	}
	(*x)++;
	if (str[*x] && str[*x][0] == '-')
		ft_init_flags(str, flags, x);
}
Example #3
0
static void		ft_extract_flg(char **str, t_flag *flg, int i, int j)
{
	while (str[i] && str[i][0] == '-' && ft_isalpha(str[i][1]))
	{
		j = 1;
		while (str[i][j] && ft_isalpha(str[i][j]))
		{
			if (str[i][j] == 'v')
				flg->verbose = 1;
			else if (str[i][j] == 'c')
				flg->color = 1;
			else if (str[i][j] == 'o')
				flg->ope = 1;
			else if (str[i][j] == 'i')
				flg->infos = 1;
			else if (str[i][j] == 's')
				flg->display = 1;
			else if (str[i][j] == 'a')
				ft_all(flg);
			else
				ft_usage(*str);
			j++;
		}
		flg->total_mod += 1;
		i++;
	}
}
Example #4
0
int			main(int argc, char **argv)
{
	t_struck			s;
	t_pc				*proc;
	unsigned long long	i[3];

	if (argc == 1)
		ft_usage();
	init_struct(&s);
	proc = NULL;
	check_valid_file(&s, argv, 0);
	map_gen(&s, &proc, -1, i);
	s.pro = &proc;
	if (s.rep & GRAPH)
	{
		init_graph(&s);
		mlx_hook(s.img.win, 2, (1l << 0), key_functions, &s);
		mlx_hook(s.img.menu, 2, (1l << 0), key_functions, &s);
		s.rep ^= STOP;
		mlx_loop_hook(s.img.mlx, aff_graph, &s);
		mlx_loop(s.img.mlx);
	}
	else
		launching_vm(&s);
	return (0);
}
Example #5
0
int				main(int ac, char **av)
{
	int		i;
	t_flag	flg;
	t_swap	*a;
	t_swap	*b;

	a = NULL;
	b = NULL;
	i = ac - 1;
	if (ac < 2)
		ft_usage(av[0]);
	else
	{
		ft_extract_stack(av, i, &a, &flg);
		i == flg.total_mod ? ft_error() : 0;
		ft_check_duplicates(a);
		ft_init_b(i - flg.total_mod, &b);
		ft_end(a);
		ft_end(b);
		flg.infos ? ft_print_infos(a) : 0;
		a->next == NULL ? ft_exit_one_nb(a, flg) : 0;
		ft_is_sorted(a) && ft_is_null(b) ? ft_exit_already_ordered(a, flg) : 0;
		ft_launcher(a, b, &flg);
	}
	return (0);
}
Example #6
0
int main(int argc, char **argv)
{
	int op, ret;
		
	opts = INIT_OPTS;
	hints = fi_allocinfo();
	if (!hints)
		return EXIT_FAILURE;

	while ((op = getopt(argc, argv, "h" ADDR_OPTS INFO_OPTS)) != -1) {
		switch (op) {
		default:
			ft_parse_addr_opts(op, optarg, &opts);
			ft_parseinfo(op, optarg, hints);
			break;
		case '?':
		case 'h':
			ft_usage(argv[0], "A simple RDM client-sever RMA example.");
			return EXIT_FAILURE;
		}
	}

	if (optind < argc)
		opts.dst_addr = argv[optind];

	hints->ep_attr->type = FI_EP_RDM;
	hints->caps = FI_MSG | FI_RMA;
	// FI_PROV_MR_ATTR flag is not set
	hints->mode = FI_CONTEXT;

	ret = run_test();
	fi_freeinfo(hints);
	fi_freeinfo(fi);
	return -ret;
}
Example #7
0
int					ft_read_params(int ac, int i, char **av, t_env *env)
{
	if (!ft_strcmp(av[i], "-n") && !env->team)
	{
		if (i + 1 == ac)
			return (error("Please enter a valid team name"));
		else
			env->team = av[i + 1];
	}
	else if (!ft_strcmp(av[i], "-p") && !env->port)
	{
		if (i + 1 == ac || (env->port = ft_atoi(av[i + 1])) < 1)
			return (error("Please enter a valid port"));
	}
	else if (!ft_strcmp(av[i], "-h") && !env->addr)
	{
		if (i + 1 < ac)
			env->addr = av[i + 1];
	}
	else
	{
		ft_usage(av[0]);
		return (-1);
	}
	return (0);
}
Example #8
0
int main(int argc, char **argv)
{
	int op, ret;
	opts = INIT_OPTS;

	hints = fi_allocinfo();
	if (!hints)
		return EXIT_FAILURE;

	while ((op = getopt(argc, argv, "h" ADDR_OPTS INFO_OPTS)) != -1) {
		switch (op) {
		default:
			ft_parse_addr_opts(op, optarg, &opts);
			ft_parseinfo(op, optarg, hints);
			break;
		case '?':
		case 'h':
			ft_usage(argv[0], "An RDM client-server example that uses shared context.\n");
			return EXIT_FAILURE;
		}
	}

	if (optind < argc)
		opts.dst_addr = argv[optind];
	
	hints->ep_attr->type = FI_EP_RDM;
	hints->caps = FI_MSG | FI_NAMED_RX_CTX;
	hints->mode = FI_CONTEXT | FI_LOCAL_MR;
	hints->addr_format = FI_SOCKADDR;

	ret = run();
	fi_freeinfo(hints);
	fi_freeinfo(fi);
	return -ret;
}
Example #9
0
static void usage(char *progname)
{
	ft_usage(progname, "Connection establishment test");
	FT_PRINT_OPTS_USAGE("-c <connections>", "# of connections");
	FT_PRINT_OPTS_USAGE("-C <message_count>", "Message count");
	FT_PRINT_OPTS_USAGE("-S <message_size>", "Message size");
	exit(1);
}
Example #10
0
int main(int ac, char **av)
{
	if (ac > 1)
		ft_ping(av);
	else
		ft_usage();
	return 0;
}
Example #11
0
static void usage(char *argv0)
{
	ft_usage(argv0, "Reliable Connection Pingpong test");
	FT_PRINT_OPTS_USAGE("-S <size>", "size of message to exchange (default 4096)");
	// No provider support yet
	// printf("  -m, --mtu=<size>       path MTU (default 1024)\n");
	FT_PRINT_OPTS_USAGE("-r <rx-depth>", "number of receives to post at a time (default 500)");
	FT_PRINT_OPTS_USAGE("-n <iters>",  "number of exchanges (default 1000)");
	FT_PRINT_OPTS_USAGE("-e",         "sleep on CQ events (default poll)");
}
Example #12
0
int main(int argc, char **argv)
{
	int op, ret;

	opts = INIT_OPTS;
	hints = fi_allocinfo();
	if (!hints)
		return EXIT_FAILURE;

	while ((op = getopt(argc, argv, "h" ADDR_OPTS INFO_OPTS)) != -1) {
		switch (op) {
		default:
			ft_parse_addr_opts(op, optarg, &opts);
			ft_parseinfo(op, optarg, hints);
			break;
		case '?':
		case 'h':
			ft_usage(argv[0], "A simple MSG client-sever example that "
				"demonstrates one possible usage of the underlying "
				"cq wait objects.");
			return EXIT_FAILURE;
		}
	}

	if (optind < argc)
		opts.dst_addr = argv[optind];

	hints->ep_attr->type	= FI_EP_MSG;
	hints->caps		= FI_MSG;
	hints->mode		= FI_LOCAL_MR;
	hints->addr_format	= FI_SOCKADDR;

	/* Fabric and connection setup */
	if (!opts.dst_addr) {
		ret = server_listen();
		if (ret)
			return -ret;
	}

	ret = opts.dst_addr ? client_connect() : server_connect();
	if (ret) {
		return -ret;
	}

	/* Exchange data */
	ret = send_recv();

	fi_shutdown(ep, 0);
	free_ep_res();
	fi_close(&cmeq->fid);
	fi_close(&dom->fid);
	fi_close(&fab->fid);

	return ret;
}
Example #13
0
void		frac_init(t_all *all, int argc, char *argv[])
{
	if (argc != 3)
		ft_usage();
	else
	{
		if (ft_strcmp(argv[1], "-cpu") == 0)
			all->cuda_frac = 0;
		else if (ft_strcmp(argv[1], "-gpu") == 0)
			all->cuda_frac = 1;
		else
			ft_usage();
		if (ft_strcmp(argv[2], "mandelbrot") == 0)
			all->frac_no = 1;
		else if (ft_strcmp(argv[2], "julia") == 0)
			all->frac_no = 2;
		else if (ft_strcmp(argv[2], "douady") == 0)
			all->frac_no = 3;
		else
			ft_usage();
		all_init(all);
	}
}
Example #14
0
void ft_csusage(char *name, char *desc)
{
	ft_usage(name, desc);
	FT_PRINT_OPTS_USAGE("-I <number>", "number of iterations");
	FT_PRINT_OPTS_USAGE("-w <number>", "number of warmup iterations");
	FT_PRINT_OPTS_USAGE("-S <size>", "specific transfer size or 'all'");
	FT_PRINT_OPTS_USAGE("-l", "align transmit and receive buffers to page size");
	FT_PRINT_OPTS_USAGE("-m", "machine readable output");
	FT_PRINT_OPTS_USAGE("-t <type>", "completion type [queue, counter]");
	FT_PRINT_OPTS_USAGE("-c <method>", "completion method [spin, sread, fd]");
	FT_PRINT_OPTS_USAGE("-h", "display this help output");

	return;
}
Example #15
0
int	main(int argc, char **argv)
{
	t_tetri tab[26];
	t_map	*map;
	int		coor[2];

	if (argc != 2)
		ft_usage();
	coor[0] = 10;
	coor[1] = 0;
	ft_check_and_parse(argv, tab, 'A', coor);
	map = ft_create_tab(tab);
	ft_recursive(map, tab);
	return (0);
}
Example #16
0
int					ft_flags3(char **str, struct s_flags *flags, int *x)
{
	if (str[*x][1] == 'd')
	{
		flags->d = 1;
		(*x)++;
		if (str[*x] && ft_isdigit(str[*x]))
			flags->dnbr = ft_atoi(str[*x]);
		else
			ft_usage();
	}
	else if (str[*x][1] == 's')
	{
		flags->s = 1;
		(*x)++;
		if (str[*x] && ft_isdigit(str[*x]))
			flags->snbr = ft_atoi(str[*x]);
		else
			ft_usage();
	}
	else
		return (0);
	return (1);
}
Example #17
0
int main(int argc, char **argv)
{
	int op, ret;

	opts = INIT_OPTS;
	opts.options |= FT_OPT_SIZE | FT_OPT_OOB_CTRL;

	hints = fi_allocinfo();
	if (!hints)
		return EXIT_FAILURE;

	hints->ep_attr->type = FI_EP_RDM;

	while ((op = getopt(argc, argv, "h" ADDR_OPTS INFO_OPTS)) != -1) {
		switch (op) {
		default:
			ft_parse_addr_opts(op, optarg, &opts);
			ft_parseinfo(op, optarg, hints, &opts);
			break;
		case '?':
		case 'h':
			ft_usage(argv[0], "AV communication unit test.");
			return EXIT_FAILURE;
		}
	}

	if (optind < argc)
		opts.dst_addr = argv[optind];

	hints->caps = hints->ep_attr->type == FI_EP_RDM ?
		      FI_TAGGED : FI_MSG;
	hints->mode = FI_CONTEXT;
	hints->domain_attr->mr_mode = opts.mr_mode;
	base_hints = hints;

	ret = av_removal_test();
	if (ret && ret != -FI_ENODATA)
		goto out;

	if (opts.dst_addr)
		sleep(1);
	ret = av_reinsert_test();
	if (ret && ret != -FI_ENODATA)
		goto out;

out:
	return ft_exit_code(ret);
}
Example #18
0
int main(int argc, char **argv)
{
	int op;
	int ret = 0;

	opts = INIT_OPTS;
	opts.transfer_size = 256;

	hints = fi_allocinfo();
	if (!hints)
		return EXIT_FAILURE;

	while ((op = getopt(argc, argv, "c:vh" ADDR_OPTS INFO_OPTS)) != -1) {
		switch (op) {
		default:
			ft_parse_addr_opts(op, optarg, &opts);
			ft_parseinfo(op, optarg, hints);
			break;
		case 'c':
			num_eps = atoi(optarg);
			break;
		case 'v':
			opts.options |= FT_OPT_VERIFY_DATA;
			break;
		case '?':
		case 'h':
			ft_usage(argv[0], "Multi endpoint test");
			FT_PRINT_OPTS_USAGE("-c <int>",
				"number of endpoints to create and test (def 3)");
			FT_PRINT_OPTS_USAGE("-v", "Enable DataCheck testing");
			return EXIT_FAILURE;
		}
	}

	if (optind < argc)
		opts.dst_addr = argv[optind];

	ft_skip_mr = 1;
	hints->caps = FI_MSG;
	hints->mode = FI_CONTEXT;

	ret = run_test();

	free_ep_res();
	ft_free_res();
	return ft_exit_code(ret);
}
Example #19
0
int main(int argc, char **argv)
{
	int op, ret = 0;

	opts = INIT_OPTS;
	opts.options |= FT_OPT_SIZE;

	hints = fi_allocinfo();
	if (!hints)
		return EXIT_FAILURE;

	while ((op = getopt(argc, argv, "h" ADDR_OPTS INFO_OPTS)) != -1) {
		switch (op) {
		default:
			ft_parse_addr_opts(op, optarg, &opts);
			ft_parseinfo(op, optarg, hints);
			break;
		case '?':
		case 'h':
			ft_usage(argv[0], "A client-server example that uses poll.\n");
			return EXIT_FAILURE;
		}
	}

	if (optind < argc)
		opts.dst_addr = argv[optind];

	hints->ep_attr->type = FI_EP_RDM;
	hints->caps = FI_MSG;
	hints->mode = FI_CONTEXT | FI_LOCAL_MR;

	ret = init_fabric();
	if (ret)
		return -ret;

	ret = init_av();
	if (ret)
		return ret;

	/* Exchange data */
	ret = send_recv();

	ft_free_res();
	return ret;
}
Example #20
0
int				main(int ac, char **av)
{
	t_env		e;
	static char	*fract[] = {FRACTAL_NAMES, 0};
	static void	(*draw[])(t_env *, t_img *) = {FRACTAL_FUNCT};

	e.fract = fract;
	e.draw = draw;
	e.mlx = NULL;
	init_img(&e.one);
	init_img(&e.two);
	e.local_endian = 0x11223344;
	e.local_endian = (((unsigned char *)&e.local_endian)[0] == 0x11) ? 1 : 0;
	if (ac > 1 && !ft_get_fractal_name(av, &e))
		ft_fractol(&e);
	ft_usage(av[0], &e);
	return (EXIT_FAILURE);
}
Example #21
0
int main(int argc, char **argv)
{
	int op, ret;
	opts = INIT_OPTS;

	hints = fi_allocinfo();
	if (!hints)
		return EXIT_FAILURE;

	while ((op = getopt(argc, argv, "h" ADDR_OPTS INFO_OPTS)) != -1) {
		switch (op) {			
		default:
			ft_parse_addr_opts(op, optarg, &opts);
			ft_parseinfo(op, optarg, hints);
			break;
		case '?':
		case 'h':
			ft_usage(argv[0], "A simple RDM client-sever example.");
			return EXIT_FAILURE;
		}
	}
	
	if (optind < argc)
		opts.dst_addr = argv[optind];
	
	hints->ep_attr->type	= FI_EP_RDM;
	hints->caps		= FI_MSG;
	hints->mode		= FI_CONTEXT;

	/* Fabric initialization */
	ret = init_fabric();
	if(ret)
		return -ret;

	/* Exchange data */
	ret = send_recv();

	free_ep_res();
	fi_close(&dom->fid);
	fi_close(&fab->fid);
	fi_freeinfo(hints);
	fi_freeinfo(fi);
	return ret;
}
Example #22
0
int					ft_parse(int ac, char **av, t_env *env)
{
	int				i;

	if (ac < 5)
	{
		ft_usage(av[0]);
		return (-1);
	}
	i = 1;
	while (i < ac)
	{
		if (ft_read_params(ac, i, av, env) < 0)
			return (ERR);
		i += 2;
	}
	env->addr = (!env->addr ? ft_strdup("localhost") : ft_strdup(env->addr));
	return (0);
}
Example #23
0
File: main.c Project: jdG-/zap
int						main(int argc, char **argv)
{
	t_game				game;

	singleton(&game);
	signal(SIGINT, exit);
	srand(time(NULL));
	if (argc == 1)
		ft_usage(argv[0]);
	ft_init_game(&game);
	ft_check_args(argv, &game);
	ft_init_map(&game);
	atexit(ft_quit);
	ft_resource(&game);
	game.sock = create_server(game);
	ft_init_cls(&game);
	ft_serveur(&game);
	return (0);
}
Example #24
0
int main(int argc, char **argv)
{
	int op, ret;

	opts = INIT_OPTS;
	opts.options |= FT_OPT_SIZE;

	hints = fi_allocinfo();
	if (!hints)
		return EXIT_FAILURE;

	while ((op = getopt(argc, argv, "q:h" ADDR_OPTS INFO_OPTS)) != -1) {
		switch (op) {
		case 'q':
			sock_service = optarg;
			break;
		default:
			ft_parse_addr_opts(op, optarg, &opts);
			ft_parseinfo(op, optarg, hints);
			break;
		case '?':
		case 'h':
			ft_usage(argv[0],
					"A MSG client-sever example that uses CM data.");
			FT_PRINT_OPTS_USAGE("-q <service_port>", "management port");
			return EXIT_FAILURE;
		}
	}

	if (optind < argc)
		opts.dst_addr = argv[optind];

	hints->ep_attr->type	= FI_EP_MSG;
	hints->caps		= FI_MSG;
	hints->mode		= FI_LOCAL_MR;
	ft_skip_mr = 1;

	ret = run();

	ft_free_res();
	return -ret;
}
Example #25
0
int		main(int ac, char **av)
{
	t_tetr	*start;
	int		nb;

	start = NULL;
	if (ac == 2)
	{
		if ((nb = ft_get_tetr(av[1], &start)) == -1)
		{
			ft_error();
			ft_free_list(start);
			return (0);
		}
		nb = ft_size_map(nb);
		ft_solve(nb, start);
	}
	else
		ft_usage();
}
Example #26
0
int				main(int ac, char **av)
{
	t_env		e;
	t_map		*map;

	if (ac < 2 || ac > 5)
		ft_usage();
	else if ((map = get_map(av[1])))
	{
		ft_init_env(&e, av);
		ft_putendl("Getting your maps' coordonates...");
		if ((e.coord = get_coord(map, &e, NULL)))
		{
			ft_free_map(&map);
			fdf(&e);
			ft_free_all(&e);
		}
	}
	return (EXIT_FAILURE);
}
Example #27
0
int main(int argc, char **argv)
{
	int op, ret;

	opts = INIT_OPTS;
	opts.options |= FT_OPT_SIZE;
	opts.comp_method = FT_COMP_SREAD;

	hints = fi_allocinfo();
	if (!hints)
		return EXIT_FAILURE;

	while ((op = getopt(argc, argv, "h" ADDR_OPTS INFO_OPTS)) != -1) {
		switch (op) {
		default:
			ft_parse_addr_opts(op, optarg, &opts);
			ft_parseinfo(op, optarg, hints);
			break;
		case '?':
		case 'h':
			ft_usage(argv[0], "A client-server example that transfers CQ data.\n");
			return EXIT_FAILURE;
		}
	}

	if (optind < argc)
		opts.dst_addr = argv[optind];

	hints->domain_attr->cq_data_size = 4;  /* required minimum */

	hints->ep_attr->type = FI_EP_MSG;
	hints->caps = FI_MSG;
	hints->mode = FI_LOCAL_MR;

	cq_attr.format = FI_CQ_FORMAT_DATA;

	ret = run();

	ft_free_res();
	return -ret;
}
Example #28
0
int main(int argc, char **argv)
{
	int op, ret;

	opts = INIT_OPTS;
	opts.options |= FT_OPT_SIZE;
	opts.comp_method = FT_COMP_WAIT_FD;

	hints = fi_allocinfo();
	if (!hints)
		return EXIT_FAILURE;

	while ((op = getopt(argc, argv, "h" ADDR_OPTS INFO_OPTS)) != -1) {
		switch (op) {
		default:
			ft_parse_addr_opts(op, optarg, &opts);
			ft_parseinfo(op, optarg, hints);
			break;
		case '?':
		case 'h':
			ft_usage(argv[0], "A simple MSG client-sever example that "
				"demonstrates one possible usage of the underlying "
				"cq wait objects.");
			return EXIT_FAILURE;
		}
	}

	if (optind < argc)
		opts.dst_addr = argv[optind];

	hints->ep_attr->type		= FI_EP_MSG;
	hints->caps			= FI_MSG;
	hints->domain_attr->mr_mode 	= FI_MR_LOCAL | OFI_MR_BASIC_MAP;

	ret = run();

	ft_free_res();
	close(epfd);
	return ft_exit_code(ret);
}
Example #29
0
int main(int argc, char **argv)
{
	int ret, op;

	opts = INIT_OPTS;
	opts.options |= FT_OPT_SIZE;
	opts.comp_method = FT_COMP_SREAD;

	hints = fi_allocinfo();
	if (!hints) {
		FT_PRINTERR("fi_allocinfo", -FI_ENOMEM);
		return EXIT_FAILURE;
	}

	while ((op = getopt(argc, argv, "h" ADDR_OPTS INFO_OPTS)) != -1) {
		switch (op) {
		default:
			ft_parse_addr_opts(op, optarg, &opts);
			ft_parseinfo(op, optarg, hints);
			break;
		case '?':
		case 'h':
			ft_usage(argv[0], "An RDM client-server example that uses tagged search.\n");
			return EXIT_FAILURE;
		}
	}

	if (optind < argc)
		opts.dst_addr = argv[optind];

	hints->rx_attr->total_buffered_recv = 1024;
	hints->ep_attr->type = FI_EP_RDM;
	hints->caps = FI_MSG | FI_TAGGED;
	hints->mode = FI_CONTEXT | FI_LOCAL_MR;

	ret = run();

	ft_free_res();
	return -ret;
}
Example #30
0
int main(int argc, char **argv)
{
	int ret, op;

	opts = INIT_OPTS;
	opts.options = FT_OPT_SIZE;

	hints = fi_allocinfo();
	if (!hints)
		return EXIT_FAILURE;

	while ((op = getopt(argc, argv, "h" ADDR_OPTS INFO_OPTS)) != -1) {
		switch (op) {
		default:
			ft_parse_addr_opts(op, optarg, &opts);
			ft_parseinfo(op, optarg, hints);
			break;
		case '?':
		case 'h':
			ft_usage(argv[0], "An RDM client-server example with scalable endpoints.\n");
			return EXIT_FAILURE;
		}
	}

	if (optind < argc)
		opts.dst_addr = argv[optind];

	hints->ep_attr->type = FI_EP_RDM;
	hints->caps = FI_MSG | FI_NAMED_RX_CTX;
	hints->mode = FI_LOCAL_MR;

	ret = run();

	free_res();
	/* Closes the scalable ep that was allocated in the test */
	FT_CLOSE_FID(sep);
	ft_free_res();
	return -ret;
}