示例#1
0
文件: flags.c 项目: magouin/Corewar
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);
}
示例#2
0
文件: fdf_map.c 项目: sbenning42/42
int				fdf_map_attr(t_env *e, t_list *lst)
{
	t_lex_tk	*t;
	int			x;
	int			max;

	if (!lst)
		return (ft_verbose(e->av, e->id, "File seems to be empty..."));
	x = 0;
	while (lst)
	{
		t = (t_lex_tk *)lst->content;
		if (t->type == Unknow)
			return (fdf_synerror(e, t, e->map->y + 1));
		else if (t->type == Eol)
			fdf_maj_xy(e->map, &x);
		lst = lst->next;
		x++;
	}
	max = (e->map->x > e->map->y ? e->map->x : e->map->y);
	e->map->gap = (FDF_SCREEN / 3.0) / max;
	if (!(e->map->m = fdf_newpxmat(e->map->x * e->map->y)))
		return (ft_err(e->av, e->id, "Memory allocation failed"));
	return (1);
}